mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 19:04:46 +00:00
19 lines
449 B
TypeScript
19 lines
449 B
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { sleep } from '.';
|
|
|
|
describe('sleep', () => {
|
|
beforeEach(() => {
|
|
vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
});
|
|
|
|
it('delay execution by the specified amount of time', async () => {
|
|
const start = performance.now();
|
|
const delay = 100;
|
|
|
|
await sleep(delay);
|
|
|
|
const end = performance.now();
|
|
|
|
expect(end - start).toBeGreaterThan(delay - 5);
|
|
});
|
|
}); |