You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
9 years ago
|
import Vue from 'vue'
|
||
|
|
||
9 years ago
|
describe('Global API: assets', () => {
|
||
9 years ago
|
const Test = Vue.extend()
|
||
|
|
||
9 years ago
|
it('directive / transition / filters', () => {
|
||
|
const assets = ['directive', 'transition', 'filter']
|
||
9 years ago
|
assets.forEach(function (type) {
|
||
|
const def = {}
|
||
|
Test[type]('test', def)
|
||
|
expect(Test.options[type + 's'].test).toBe(def)
|
||
|
expect(Test[type]('test')).toBe(def)
|
||
|
// extended registration should not pollute global
|
||
|
expect(Vue.options[type + 's'].test).toBeUndefined()
|
||
|
})
|
||
|
})
|
||
|
|
||
9 years ago
|
describe('Vue.component', () => {
|
||
9 years ago
|
it('should register a component', () => {
|
||
|
Vue.component('foo', {
|
||
|
template: '<span>foo</span>'
|
||
|
})
|
||
|
Vue.component('bar', {
|
||
|
template: '<span>bar</span>'
|
||
|
})
|
||
|
const vm = new Vue({
|
||
|
template: '<div><foo></foo><bar></bar></div>'
|
||
9 years ago
|
}).$mount()
|
||
9 years ago
|
expect(vm.$el.innerHTML).toBe('<span>foo</span><span>bar</span>')
|
||
9 years ago
|
// unregister them
|
||
|
delete Vue.options.components.foo
|
||
|
delete Vue.options.components.bar
|
||
9 years ago
|
})
|
||
|
})
|
||
9 years ago
|
|
||
|
it('component on extended constructor', () => {
|
||
|
const def = { a: 1 }
|
||
|
Test.component('test', def)
|
||
|
const component = Test.options.components.test
|
||
|
expect(typeof component).toBe('function')
|
||
|
expect(component.super).toBe(Vue)
|
||
|
expect(component.options.a).toBe(1)
|
||
|
expect(component.options.name).toBe('test')
|
||
|
expect(Test.component('test')).toBe(component)
|
||
|
// already extended
|
||
|
Test.component('test2', component)
|
||
|
expect(Test.component('test2')).toBe(component)
|
||
|
// extended registration should not pollute global
|
||
|
expect(Vue.options.components.test).toBeUndefined()
|
||
|
})
|
||
9 years ago
|
})
|