Преглед изворни кода

refactor: improve test case

Evan You пре 7 година
родитељ
комит
173042bb8e
1 измењених фајлова са 4 додато и 6 уклоњено
  1. 4 6
      test/unit/modules/util/invoke-with-error-handling.spec.js

+ 4 - 6
test/unit/modules/util/invoke-with-error-handling.spec.js

@@ -4,18 +4,16 @@ import { invokeWithErrorHandling } from 'core/util/error'
 describe('invokeWithErrorHandling', () => {
   if (typeof Promise !== 'undefined') {
     it('should errorHandler call once when nested calls return rejected promise', done => {
-      let times = 0
-
-      Vue.config.errorHandler = function () {
-        times++
-      }
+      const originalHandler = Vue.config.errorHandler
+      const handler = Vue.config.errorHandler = jasmine.createSpy()
 
       invokeWithErrorHandling(() => {
         return invokeWithErrorHandling(() => {
           return Promise.reject(new Error('fake error'))
         })
       }).then(() => {
-        expect(times).toBe(1)
+        Vue.config.errorHandler = originalHandler
+        expect(handler.calls.count()).toBe(1)
         done()
       })
     })