chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 11:55:53 +08:00
commit dde272c4b8
19405 changed files with 2730632 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { describe, it, expect, vi } from 'vitest';
import { timeOperation } from './query-timing.js';
describe('timeOperation', () => {
it('returns the result and emits success with a numeric duration', async () => {
const emit = vi.fn();
const result = await timeOperation(() => Promise.resolve('ok'), emit);
expect(result).toBe('ok');
expect(emit).toHaveBeenCalledWith('success', expect.any(Number));
});
it('re-throws and emits failure when the operation rejects', async () => {
const emit = vi.fn();
const boom = new Error('boom');
await expect(timeOperation(() => Promise.reject(boom), emit)).rejects.toBe(
boom
);
expect(emit).toHaveBeenCalledWith('failure', expect.any(Number));
});
});