Skip to content

Commit 14c40e6

Browse files
38elementseddyerburgh
authored andcommitted
fix(types): improve types (#593)
1 parent 55a4391 commit 14c40e6

File tree

4 files changed

+62
-10
lines changed

4 files changed

+62
-10
lines changed

Diff for: packages/server-test-utils/types/index.d.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
3434
slots?: Slots
3535
scopedSlots?: Record<string, string>
3636
stubs?: Stubs,
37-
attrs?: object
38-
listeners?: object
37+
attrs?: Record<string, string>
38+
listeners?: Record<string, Function | Function[]>
3939
sync?: boolean
4040
}
4141

@@ -47,6 +47,9 @@ type ThisTypedShallowOptions<V extends Vue> = ShallowOptions<V> & ThisType<V>
4747

4848
interface VueTestUtilsConfigOptions {
4949
stubs?: Stubs
50+
mocks?: object
51+
methods?: Record<string, Function>
52+
provide?: object
5053
}
5154

5255
export declare let config: VueTestUtilsConfigOptions

Diff for: packages/server-test-utils/types/test/renderToString.ts

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vuex from 'vuex'
2-
import { renderToString } from '../'
2+
import { renderToString, config } from '../'
33
import { normalOptions, functionalOptions, Normal, ClassComponent } from './resources'
44

55
const store = new Vuex.Store({})
@@ -17,12 +17,35 @@ renderToString(ClassComponent, {
1717
foo: normalOptions,
1818
bar: functionalOptions,
1919
baz: ClassComponent,
20-
qux: `<div>Test</div>`
20+
qux: `<div>Test</div>`,
21+
quux: true
2122
},
2223
attrs: {
2324
attribute: 'attr'
2425
},
2526
listeners: {
26-
listener: () => {}
27+
listener: () => {},
28+
listeners: [() => {}, () => {}]
2729
}
2830
})
31+
32+
/**
33+
* Test for config
34+
*/
35+
config.stubs = ['a']
36+
config.stubs = {
37+
foo: normalOptions,
38+
bar: functionalOptions,
39+
baz: ClassComponent,
40+
qux: `<div>Test</div>`,
41+
quux: true
42+
}
43+
config.mocks = {
44+
foo: 'bar',
45+
}
46+
config.methods = {
47+
foo: () => {}
48+
}
49+
config.provide = {
50+
foo: {}
51+
}

Diff for: packages/test-utils/types/index.d.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
124124
slots?: Slots
125125
scopedSlots?: Record<string, string>
126126
stubs?: Stubs,
127-
attrs?: object
128-
listeners?: object
127+
attrs?: Record<string, string>
128+
listeners?: Record<string, Function | Function[]>
129129
sync?: boolean
130130
}
131131

@@ -137,6 +137,9 @@ type ThisTypedShallowMountOptions<V extends Vue> = ShallowMountOptions<V> & This
137137

138138
interface VueTestUtilsConfigOptions {
139139
stubs?: Stubs
140+
mocks?: object
141+
methods?: Record<string, Function>
142+
provide?: object
140143
}
141144

142145
export declare function createLocalVue (): typeof Vue

Diff for: packages/test-utils/types/test/mount.ts

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vuex from 'vuex'
2-
import { mount, createLocalVue } from '../'
2+
import { mount, createLocalVue, config } from '../'
33
import { normalOptions, functionalOptions, Normal, ClassComponent } from './resources'
44

55
/**
@@ -40,13 +40,15 @@ mount(ClassComponent, {
4040
foo: normalOptions,
4141
bar: functionalOptions,
4242
baz: ClassComponent,
43-
qux: `<div>Test</div>`
43+
qux: `<div>Test</div>`,
44+
quux: true
4445
},
4546
attrs: {
4647
attribute: 'attr'
4748
},
4849
listeners: {
49-
listener: () => {}
50+
listener: () => {},
51+
listeners: [() => {}, () => {}]
5052
},
5153
sync: true
5254
})
@@ -69,3 +71,24 @@ mount(ClassComponent, {
6971
this.bar
7072
}
7173
})
74+
75+
/**
76+
* Test for config
77+
*/
78+
config.stubs = ['a']
79+
config.stubs = {
80+
foo: normalOptions,
81+
bar: functionalOptions,
82+
baz: ClassComponent,
83+
qux: `<div>Test</div>`,
84+
quux: true
85+
}
86+
config.mocks = {
87+
foo: 'bar',
88+
}
89+
config.methods = {
90+
foo: () => {}
91+
}
92+
config.provide = {
93+
foo: {}
94+
}

0 commit comments

Comments
 (0)