mirror of
https://github.com/nick-fields/retry.git
synced 2026-02-11 23:55:28 +00:00
Setup tests (#87)
* test: move timeout tests to their own job to speed things up slightly * test: add comment about timeout tests * test: fix needs in cd job * test: add jest configuration and first test * test: setup codecov to track coverage
This commit is contained in:
17
src/util.test.ts
Normal file
17
src/util.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'jest';
|
||||
import { getHeapStatistics } from 'v8';
|
||||
|
||||
import { wait } from './util';
|
||||
|
||||
// mocks the setTimeout function, see https://jestjs.io/docs/timer-mocks
|
||||
jest.useFakeTimers();
|
||||
jest.spyOn(global, 'setTimeout');
|
||||
|
||||
describe('util', () => {
|
||||
test('wait', async () => {
|
||||
const waitTime = 1000;
|
||||
wait(waitTime);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), waitTime);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user