Przeglądaj źródła

fix async failure

Evan You 10 lat temu
rodzic
commit
4540aaf37d
2 zmienionych plików z 5 dodań i 9 usunięć
  1. 0 4
      test/unit/features/directives/if.spec.js
  2. 5 5
      test/unit/index.js

+ 0 - 4
test/unit/features/directives/if.spec.js

@@ -30,7 +30,6 @@ describe('Directive v-if', () => {
     waitForUpdate(() => {
       expect(vm.$el.innerHTML).toBe('')
       vm.foo = {}
-      res()
     }).then(() => {
       expect(vm.$el.innerHTML).toBe('<span>hello</span>')
       vm.foo = 0
@@ -72,7 +71,6 @@ describe('Directive v-if', () => {
     waitForUpdate(() => {
       expect(vm.$el.innerHTML).toBe('<span>bye</span>')
       vm.foo = {}
-      res()
     }).then(() => {
       expect(vm.$el.innerHTML).toBe('<span>hello</span>')
       vm.foo = 0
@@ -118,7 +116,6 @@ describe('Directive v-if', () => {
     waitForUpdate(() => {
       expect(vm.$el.innerHTML).toBe('<span>2</span>')
       vm.list.push({ value: true })
-      res()
     }).then(() => {
       expect(vm.$el.innerHTML).toBe('<span>2</span><span>3</span>')
       vm.list.splice(1, 2)
@@ -150,7 +147,6 @@ describe('Directive v-if', () => {
     waitForUpdate(() => {
       expect(vm.$el.innerHTML).toBe('<span>bye</span><span>bye</span><span>hello</span>')
       vm.list.push({ value: true })
-      res()
     }).then(() => {
       expect(vm.$el.innerHTML).toBe('<span>bye</span><span>bye</span><span>hello</span><span>hello</span>')
       vm.list.splice(1, 2)

+ 5 - 5
test/unit/index.js

@@ -60,7 +60,7 @@ beforeEach(function () {
 // })
 // .catch(done)
 window.waitForUpdate = initialCb => {
-  let onError
+  let done
   const queue = [initialCb]
 
   function shift () {
@@ -70,8 +70,8 @@ window.waitForUpdate = initialCb => {
       job()
     } catch (e) {
       hasError = true
-      if (onError) {
-        onError(e)
+      if (done) {
+        done.fail(e)
       }
     }
     if (!hasError) {
@@ -88,8 +88,8 @@ window.waitForUpdate = initialCb => {
       queue.push(nextCb)
       return chainer
     },
-    catch: errorCb => {
-      onError = errorCb
+    catch: doneCb => {
+      done = doneCb
       return chainer
     }
   }