config.spec.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. })