Skip to content

Commit

Permalink
refactor: improve test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 21, 2019
1 parent 2f3020e commit 173042b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/unit/modules/util/invoke-with-error-handling.spec.js
Expand Up @@ -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()
})
})
Expand Down

0 comments on commit 173042b

Please sign in to comment.