2
0

name.spec.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import Vue from 'vue'
  2. describe('Options name', () => {
  3. it('should warn when giving instance a name', () => {
  4. new Vue({
  5. name: 'SuperVue'
  6. }).$mount()
  7. /* eslint-disable */
  8. expect(`options "name" can only be used as a component definition option, not during instance creation.`)
  9. .toHaveBeenWarned()
  10. /* eslint-enable */
  11. })
  12. it('should contain itself in self components', () => {
  13. const vm = Vue.extend({
  14. name: 'SuperVue'
  15. })
  16. expect(vm.options.components['SuperVue']).toEqual(vm)
  17. })
  18. it('should warn when incorrect name given', () => {
  19. Vue.extend({
  20. name: 'Hyper*Vue'
  21. })
  22. /* eslint-disable */
  23. expect(`Invalid component name: "Hyper*Vue". Component names can only contain alphanumeric characaters and the hyphen.`)
  24. .toHaveBeenWarned()
  25. /* eslint-enable */
  26. })
  27. it('when incorrect name given it should not contain itself in self components', () => {
  28. const vm = Vue.extend({
  29. name: 'Hyper*Vue'
  30. })
  31. expect(vm.options.components['Hyper*Vue']).toBeUndefined()
  32. })
  33. it('id should not override given name when using Vue.component', () => {
  34. const SuperComponent = Vue.component('super-component', {
  35. name: 'SuperVue'
  36. })
  37. expect(SuperComponent.options.components['SuperVue']).toEqual(SuperComponent)
  38. expect(SuperComponent.options.components['super-component']).toEqual(SuperComponent)
  39. })
  40. })