Skip to content

Commit

Permalink
test(useinterval): n
Browse files Browse the repository at this point in the history
n
  • Loading branch information
namepain committed Jan 1, 2020
1 parent 2ff9fbe commit f4d27ff
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/useInterval.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,17 @@ describe('useInterval', () => {
jest.advanceTimersByTime(200)
expect(fn1).toHaveBeenCalledTimes(4)
})

it('should call immediate', () => {
let fn = jest.fn()
expect(setTimeout).toHaveBeenCalledTimes(0)
renderHook(({ fn, delay, immediate }: params) => useInterval(fn, delay, immediate), {
initialProps: {
fn,
delay: 0,
immediate: true
}
})
expect(fn).toHaveBeenCalledTimes(1)
})
})

0 comments on commit f4d27ff

Please sign in to comment.