name.spec.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Vue from 'vue'
  2. describe('Options name', () => {
  3. it('should contain itself in self components', () => {
  4. const vm = Vue.extend({
  5. name: 'SuperVue'
  6. })
  7. expect(vm.options.components['SuperVue']).toEqual(vm)
  8. })
  9. it('should warn when incorrect name given', () => {
  10. Vue.extend({
  11. name: 'Hyper*Vue'
  12. })
  13. /* eslint-disable */
  14. expect(`Invalid component name: "Hyper*Vue".`)
  15. .toHaveBeenWarned()
  16. /* eslint-enable */
  17. Vue.extend({
  18. name: '2Cool2BValid'
  19. })
  20. /* eslint-disable */
  21. expect(`Invalid component name: "2Cool2BValid".`)
  22. .toHaveBeenWarned()
  23. /* eslint-enable */
  24. })
  25. it('id should not override given name when using Vue.component', () => {
  26. const SuperComponent = Vue.component('super-component', {
  27. name: 'SuperVue'
  28. })
  29. expect(SuperComponent.options.components['SuperVue']).toEqual(SuperComponent)
  30. expect(SuperComponent.options.components['super-component']).toEqual(SuperComponent)
  31. })
  32. it('should allow all potential custom element name for component name including non-alphanumeric characters', () => {
  33. Vue.extend({
  34. name: 'my-컴포넌트'
  35. })
  36. expect(`Invalid component name`).not.toHaveBeenWarned()
  37. })
  38. })