-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
/
Copy pathuse.spec.js
57 lines (48 loc) · 1.69 KB
/
use.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Vue from 'vue'
describe('Global API: use', () => {
const def = {}
const options = {}
const pluginStub = {
install: (Vue, opts) => {
Vue.directive('plugin-test', def)
expect(opts).toBe(options)
}
}
it('should apply Object plugin', () => {
Vue.use(pluginStub, options)
expect(Vue.options.directives['plugin-test']).toBe(def)
delete Vue.options.directives['plugin-test']
expect(Vue.options.directives['plugin-test']).toBeUndefined()
// should not double apply
Vue.use(pluginStub, options)
expect(Vue.options.directives['plugin-test']).toBeUndefined()
})
it('should apply Function plugin', () => {
Vue.use(pluginStub.install, options)
expect(Vue.options.directives['plugin-test']).toBe(def)
delete Vue.options.directives['plugin-test']
})
it('should work on extended constructors without polluting the base', () => {
const Ctor = Vue.extend({})
Ctor.use(pluginStub, options)
expect(Vue.options.directives['plugin-test']).toBeUndefined()
expect(Ctor.options.directives['plugin-test']).toBe(def)
})
// GitHub issue #5970
it('should work on multi version', () => {
const Ctor1 = Vue.extend({})
const Ctor2 = Vue.extend({})
Ctor1.use(pluginStub, options)
expect(Vue.options.directives['plugin-test']).toBeUndefined()
expect(Ctor1.options.directives['plugin-test']).toBe(def)
// multi version Vue Ctor with the same cid
Ctor2.cid = Ctor1.cid
Ctor2.use(pluginStub, options)
expect(Vue.options.directives['plugin-test']).toBeUndefined()
expect(Ctor2.options.directives['plugin-test']).toBe(def)
})
// #8595
it('chain call', () => {
expect(Vue.use(() => {})).toBe(Vue)
})
})