Skip to content

Commit

Permalink
test: test use timer in Callback
Browse files Browse the repository at this point in the history
  • Loading branch information
molvqingtai committed Apr 7, 2024
1 parent 5f58713 commit c7761b1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions __tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,16 @@ describe('Test timer', () => {
expect(callback).toHaveBeenCalledTimes(0)
})
})
describe('Test use timer in Callback', () => {
test('should emit stop event', async () => {
const callback = vi.fn()
const timer = new Timer((_, timer: Timer) => {
timer.stop()
})
timer.start()
timer.on('stop', callback)
await sleep(0)
expect(callback).toHaveBeenCalled()
})
})
})

0 comments on commit c7761b1

Please sign in to comment.