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
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:
@@ -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));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user