config.spec.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import Vue from 'vue'
  2. describe('Global config', () => {
  3. it('should warn replacing config object', () => {
  4. const originalConfig = Vue.config
  5. Vue.config = {}
  6. expect(Vue.config).toBe(originalConfig)
  7. expect('Do not replace the Vue.config object').toHaveBeenWarned()
  8. })
  9. describe('silent', () => {
  10. it('should be false by default', () => {
  11. Vue.util.warn('foo')
  12. expect('foo').toHaveBeenWarned()
  13. })
  14. it('should work when set to true', () => {
  15. Vue.config.silent = true
  16. Vue.util.warn('foo')
  17. expect('foo').not.toHaveBeenWarned()
  18. Vue.config.silent = false
  19. })
  20. })
  21. describe('optionMergeStrategies', () => {
  22. it('should allow defining custom option merging strategies', () => {
  23. const spy = jasmine.createSpy('option merging')
  24. Vue.config.optionMergeStrategies.__test__ = (parent, child, vm) => {
  25. spy(parent, child, vm)
  26. return child + 1
  27. }
  28. const Test = Vue.extend({
  29. __test__: 1
  30. })
  31. expect(spy.calls.count()).toBe(1)
  32. expect(spy).toHaveBeenCalledWith(undefined, 1, undefined)
  33. expect(Test.options.__test__).toBe(2)
  34. const test = new Test({
  35. __test__: 2
  36. })
  37. expect(spy.calls.count()).toBe(2)
  38. expect(spy).toHaveBeenCalledWith(2, 2, test)
  39. expect(test.$options.__test__).toBe(3)
  40. })
  41. })
  42. })