name.spec.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`)
  15. .toHaveBeenWarned()
  16. /* eslint-enable */
  17. Vue.extend({
  18. name: '2Cool2BValid'
  19. })
  20. /* eslint-disable */
  21. expect(`Invalid component name: "2Cool2BValid". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`)
  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. })