test: add dedupe test case for scheduler

This commit is contained in:
Evan You 2018-09-19 21:38:27 -04:00
parent 8fef446257
commit cb982099e4

View File

@ -77,4 +77,21 @@ describe('scheduler', () => {
await nextTick()
expect(calls).toEqual(['job1', 'job2', 'cb1', 'cb2'])
})
test('should dedupe queued tasks', async () => {
const calls: any = []
const job1 = () => {
calls.push('job1')
}
const job2 = () => {
calls.push('job2')
}
queueJob(job1)
queueJob(job2)
queueJob(job1)
queueJob(job2)
expect(calls).toEqual([])
await nextTick()
expect(calls).toEqual(['job1', 'job2'])
})
})