#45 : Add unit tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
setIntervalImmediate,
|
setIntervalImmediate,
|
||||||
|
wait
|
||||||
} from './interval.js'
|
} from './interval.js'
|
||||||
|
|
||||||
describe('setIntervalImmediate', () => {
|
describe('setIntervalImmediate', () => {
|
||||||
@@ -28,3 +29,18 @@ describe('setIntervalImmediate', () => {
|
|||||||
expect(clearInterval).toHaveBeenCalledWith(interval)
|
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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user