Skip to content

Commit 173042b

Browse files
committed
refactor: improve test case
1 parent 2f3020e commit 173042b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: test/unit/modules/util/invoke-with-error-handling.spec.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import { invokeWithErrorHandling } from 'core/util/error'
44
describe('invokeWithErrorHandling', () => {
55
if (typeof Promise !== 'undefined') {
66
it('should errorHandler call once when nested calls return rejected promise', done => {
7-
let times = 0
8-
9-
Vue.config.errorHandler = function () {
10-
times++
11-
}
7+
const originalHandler = Vue.config.errorHandler
8+
const handler = Vue.config.errorHandler = jasmine.createSpy()
129

1310
invokeWithErrorHandling(() => {
1411
return invokeWithErrorHandling(() => {
1512
return Promise.reject(new Error('fake error'))
1613
})
1714
}).then(() => {
18-
expect(times).toBe(1)
15+
Vue.config.errorHandler = originalHandler
16+
expect(handler.calls.count()).toBe(1)
1917
done()
2018
})
2119
})

0 commit comments

Comments
 (0)