invoke-with-error-handling.spec.js 689 B

123456789101112131415161718192021
  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. invokeWithErrorHandling(() => {
  9. return invokeWithErrorHandling(() => {
  10. return Promise.reject(new Error('fake error'))
  11. })
  12. }).then(() => {
  13. Vue.config.errorHandler = originalHandler
  14. expect(handler.calls.count()).toBe(1)
  15. done()
  16. })
  17. })
  18. }
  19. })