From cb982099e4400d246ec7aa367ad85c6ffc959bec Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 19 Sep 2018 21:38:27 -0400 Subject: [PATCH] test: add dedupe test case for scheduler --- packages/scheduler/__tests__/scheduler.spec.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/scheduler/__tests__/scheduler.spec.ts b/packages/scheduler/__tests__/scheduler.spec.ts index 60f4494b..27265c42 100644 --- a/packages/scheduler/__tests__/scheduler.spec.ts +++ b/packages/scheduler/__tests__/scheduler.spec.ts @@ -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']) + }) })