error.spec.js 824 B

123456789101112131415161718192021222324
  1. import Vue from 'vue'
  2. import { invokeWithErrorHandling } from 'core/util/error'
  3. describe('invokeWithErrorHandling', () => {
  4. if (typeof Promise !== 'undefined') {
  5. it('should errorHandler call once when nested calls return rejected promise', done => {
  6. const originalHandler = Vue.config.errorHandler
  7. const handler = Vue.config.errorHandler = jasmine.createSpy()
  8. const userCatch = jasmine.createSpy()
  9. const err = new Error('fake error')
  10. invokeWithErrorHandling(() => {
  11. return invokeWithErrorHandling(() => {
  12. return Promise.reject(err)
  13. })
  14. }).catch(userCatch).then(() => {
  15. Vue.config.errorHandler = originalHandler
  16. expect(handler.calls.count()).toBe(1)
  17. expect(userCatch).toHaveBeenCalledWith(err)
  18. done()
  19. })
  20. })
  21. }
  22. })