import Vue from 'vue'
describe('Options components', () => {
it('should accept plain object', () => {
const vm = new Vue({
template: '',
components: {
test: {
template: '
hi
'
}
}
}).$mount()
expect(vm.$el.tagName).toBe('DIV')
expect(vm.$el.textContent).toBe('hi')
})
it('should accept extended constructor', () => {
const Test = Vue.extend({
template: 'hi
'
})
const vm = new Vue({
template: '',
components: {
test: Test
}
}).$mount()
expect(vm.$el.tagName).toBe('DIV')
expect(vm.$el.textContent).toBe('hi')
})
it('should accept camelCase', () => {
const myComp = {
template: 'hi
'
}
const vm = new Vue({
template: '',
components: {
myComp
}
}).$mount()
expect(vm.$el.tagName).toBe('DIV')
expect(vm.$el.textContent).toBe('hi')
})
it('should accept PascalCase', () => {
const MyComp = {
template: 'hi
'
}
const vm = new Vue({
template: '',
components: {
MyComp
}
}).$mount()
expect(vm.$el.tagName).toBe('DIV')
expect(vm.$el.textContent).toBe('hi')
})
it('should warn native HTML elements', () => {
new Vue({
components: {
div: { template: '' }
}
})
expect('Do not use built-in or reserved HTML elements as component').toHaveBeenWarned()
})
it('should warn built-in elements', () => {
new Vue({
components: {
component: { template: '' }
}
})
expect('Do not use built-in or reserved HTML elements as component').toHaveBeenWarned()
})
})