config.spec.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Vue from 'vue'
  2. describe('Global config', () => {
  3. describe('preserveWhitespace', () => {
  4. it('should preserve whitepspaces when set to true', () => {
  5. // this option is set to false during unit tests.
  6. Vue.config.preserveWhitespace = true
  7. const vm = new Vue({
  8. template: '<div><span>hi</span> <span>ha</span></div>'
  9. }).$mount()
  10. expect(vm.$el.innerHTML).toBe('<span>hi</span> <span>ha</span>')
  11. Vue.config.preserveWhitespace = false
  12. })
  13. it('should remove whitespaces when set to false', () => {
  14. const vm = new Vue({
  15. template: '<div><span>hi</span> <span>ha</span></div>'
  16. }).$mount()
  17. expect(vm.$el.innerHTML).toBe('<span>hi</span><span>ha</span>')
  18. })
  19. })
  20. describe('silent', () => {
  21. it('should be false by default', () => {
  22. Vue.util.warn('foo')
  23. expect('foo').toHaveBeenWarned()
  24. })
  25. it('should work when set to true', () => {
  26. Vue.config.silent = true
  27. Vue.util.warn('foo')
  28. expect('foo').not.toHaveBeenWarned()
  29. Vue.config.silent = false
  30. })
  31. })
  32. describe('errorHandler', () => {
  33. it('should be called with correct args', () => {
  34. const spy = jasmine.createSpy('errorHandler')
  35. Vue.config.errorHandler = spy
  36. const err = new Error()
  37. const vm = new Vue({
  38. render () { throw err }
  39. }).$mount()
  40. expect(spy).toHaveBeenCalledWith(err, vm)
  41. Vue.config.errorHandler = null
  42. })
  43. })
  44. })