name.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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".`).toHaveBeenWarned()
  15. /* eslint-enable */
  16. Vue.extend({
  17. name: '2Cool2BValid'
  18. })
  19. /* eslint-disable */
  20. expect(`Invalid component name: "2Cool2BValid".`).toHaveBeenWarned()
  21. /* eslint-enable */
  22. })
  23. it('id should not override given name when using Vue.component', () => {
  24. const SuperComponent = Vue.component('super-component', {
  25. name: 'SuperVue'
  26. })!
  27. expect(SuperComponent.options.components['SuperVue']).toEqual(
  28. SuperComponent
  29. )
  30. expect(SuperComponent.options.components['super-component']).toEqual(
  31. SuperComponent
  32. )
  33. })
  34. it('should allow all potential custom element name for component name including non-alphanumeric characters', () => {
  35. Vue.extend({
  36. name: 'my-컴포넌트'
  37. })
  38. expect(`Invalid component name`).not.toHaveBeenWarned()
  39. })
  40. })