config.spec.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import Vue from 'vue'
  2. import { warn } from 'core/util/debug'
  3. describe('Global config', () => {
  4. it('should warn replacing config object', () => {
  5. const originalConfig = Vue.config
  6. Vue.config = {}
  7. expect(Vue.config).toBe(originalConfig)
  8. expect('Do not replace the Vue.config object').toHaveBeenWarned()
  9. })
  10. describe('silent', () => {
  11. it('should be false by default', () => {
  12. warn('foo')
  13. expect('foo').toHaveBeenWarned()
  14. })
  15. it('should work when set to true', () => {
  16. Vue.config.silent = true
  17. warn('foo')
  18. expect('foo').not.toHaveBeenWarned()
  19. Vue.config.silent = false
  20. })
  21. })
  22. describe('optionMergeStrategies', () => {
  23. it('should allow defining custom option merging strategies', () => {
  24. const spy = jasmine.createSpy('option merging')
  25. Vue.config.optionMergeStrategies.__test__ = (parent, child, vm) => {
  26. spy(parent, child, vm)
  27. return child + 1
  28. }
  29. const Test = Vue.extend({
  30. __test__: 1
  31. })
  32. expect(spy.calls.count()).toBe(1)
  33. expect(spy).toHaveBeenCalledWith(undefined, 1, undefined)
  34. expect(Test.options.__test__).toBe(2)
  35. const test = new Test({
  36. __test__: 2
  37. })
  38. expect(spy.calls.count()).toBe(2)
  39. expect(spy).toHaveBeenCalledWith(2, 2, test)
  40. expect(test.$options.__test__).toBe(3)
  41. })
  42. })
  43. describe('ignoredElements', () => {
  44. it('should work', () => {
  45. Vue.config.ignoredElements = ['foo', /^ion-/]
  46. new Vue({
  47. template: `<div><foo/><ion-foo/><ion-bar/></div>`
  48. }).$mount()
  49. expect('Unknown custom element').not.toHaveBeenWarned()
  50. Vue.config.ignoredElements = []
  51. })
  52. })
  53. })