#45 : Add unit tests

This commit is contained in:
Vadim
2021-07-18 16:18:45 +03:00
parent 08ad962dad
commit 00e0a2a471

View File

@@ -1,5 +1,6 @@
import {
setIntervalImmediate,
wait
} from './interval.js'
describe('setIntervalImmediate', () => {
@@ -28,3 +29,18 @@ describe('setIntervalImmediate', () => {
expect(clearInterval).toHaveBeenCalledWith(interval)
})
})
describe('wait', () => {
beforeEach(() => {
jest.useFakeTimers();
})
it('wait n ms', () => {
const ms = 1000
wait(ms)
jest.runAllTimers()
expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), ms)
})
})