]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: add dedupe test case for scheduler
authorEvan You <yyx990803@gmail.com>
Thu, 20 Sep 2018 01:38:27 +0000 (21:38 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 20 Sep 2018 01:38:27 +0000 (21:38 -0400)
packages/scheduler/__tests__/scheduler.spec.ts

index 60f4494bf9fe45c0865aedeef786d30790243665..27265c422d6f0c3c4a5bdf4b0c2006744fce1fcf 100644 (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'])
+  })
 })