-
Notifications
You must be signed in to change notification settings - Fork 668
/
Copy pathmount.ts
67 lines (59 loc) · 1.3 KB
/
mount.ts
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
58
59
60
61
62
63
64
65
66
67
import Vuex from 'vuex'
import { mount, createLocalVue } from '../'
import { normalOptions, functionalOptions, Normal, ClassComponent } from './resources'
/**
* Should create wrapper vm based on (function) component options or constructors
* The users can specify component type via the type parameter
*/
const normalWrapper = mount(normalOptions)
const normalFoo: string = normalWrapper.vm.foo
const classWrapper = mount(ClassComponent)
const classFoo: string = classWrapper.vm.bar
const functinalWrapper = mount(functionalOptions)
/**
* Test for mount options
*/
const localVue = createLocalVue()
localVue.use(Vuex)
const store = new Vuex.Store({})
mount(ClassComponent, {
attachToDocument: true,
localVue,
mocks: {
$store: store
},
slots: {
default: `<div>Foo</div>`,
foo: [normalOptions, functionalOptions],
bar: ClassComponent
},
stubs: {
foo: normalOptions,
bar: functionalOptions,
baz: ClassComponent,
qux: `<div>Test</div>`
},
attrs: {
attribute: 'attr'
},
listeners: {
listener: () => {}
}
})
mount(functionalOptions, {
context: {
props: { foo: 'test' }
},
stubs: ['child']
})
/**
* MountOptions should receive Vue's component options
*/
mount(ClassComponent, {
propsData: {
test: 'test'
},
created () {
this.bar
}
})