Skip to content

Commit 2c201c1

Browse files
committed
chore: uncommented new prop tests and add defaultProps to all mount
1 parent b4597d3 commit 2c201c1

File tree

3 files changed

+31
-43
lines changed

3 files changed

+31
-43
lines changed

src/mount.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ export function mount<V, P>(
6666
props(Props: P): any
6767
registerHooks(keys: string[]): void
6868
},
69-
options?: MountingOptions<P>
69+
options?: MountingOptions<P & PublicProps>
7070
): VueWrapper<ComponentPublicInstance<V>>
7171

7272
// Functional component with emits
7373
export function mount<Props, E extends EmitsOptions = {}>(
7474
originalComponent: FunctionalComponent<Props, E>,
75-
options?: MountingOptions<Props>
75+
options?: MountingOptions<Props & PublicProps>
7676
): VueWrapper<ComponentPublicInstance<Props>>
7777

7878
// Component declared with defineComponent
@@ -150,7 +150,7 @@ export function mount<
150150
Extends,
151151
EE
152152
>,
153-
options?: MountingOptions<never, D>
153+
options?: MountingOptions<PublicProps, D>
154154
): VueWrapper<
155155
ComponentPublicInstance<Props, RawBindings, D, C, M, E, VNodeProps & Props>
156156
>
@@ -182,7 +182,7 @@ export function mount<
182182
EE,
183183
Props
184184
>,
185-
options?: MountingOptions<Props, D>
185+
options?: MountingOptions<Props & PublicProps, D>
186186
): VueWrapper<ComponentPublicInstance<Props, RawBindings, D, C, M, E>>
187187

188188
// Component declared with { props: { ... } }
@@ -210,7 +210,7 @@ export function mount<
210210
Extends,
211211
EE
212212
>,
213-
options?: MountingOptions<ExtractPropTypes<PropsOptions>, D>
213+
options?: MountingOptions<ExtractPropTypes<PropsOptions> & PublicProps, D>
214214
): VueWrapper<
215215
ComponentPublicInstance<
216216
ExtractPropTypes<PropsOptions>,

test-dts/mount.d-test.ts

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ expectType<string>(
4444
// })
4545
// )
4646

47-
// can not receive extra props
48-
// expectError(
49-
// mount(AppWithDefine, {
50-
// props: { a: 'Hello', c: 2 }
51-
// })
52-
// )
47+
// allow extra props, like using `h()`
48+
mount(AppWithDefine, {
49+
props: { a: 'Hello', c: 2 }
50+
})
5351

5452
// wrong prop type should not compile
5553
expectError(
@@ -75,12 +73,9 @@ expectType<string>(
7573
}).vm.a
7674
)
7775

78-
// can't receive extra props
79-
// expectError(
80-
// mount(AppWithProps, {
81-
// props: { a: 'Hello', b: 2 }
82-
// })
83-
// )
76+
mount(AppWithProps, {
77+
props: { a: 'Hello', b: 2 }
78+
})
8479

8580
// wrong prop type should not compile
8681
expectError(
@@ -109,20 +104,17 @@ expectType<number>(
109104
}).vm.b
110105
)
111106

112-
// // cannot receive extra props
113-
// // if they pass use object inside
114-
// expectError(
115-
// mount(
116-
// {
117-
// props: ['a']
118-
// },
119-
// {
120-
// props: {
121-
// b: 2
122-
// }
123-
// }
124-
// )
125-
// )
107+
// allow extra props, like using `h()`
108+
mount(
109+
{
110+
props: ['a']
111+
},
112+
{
113+
props: {
114+
b: 2
115+
}
116+
}
117+
)
126118

127119
const AppWithoutProps = {
128120
template: ''

test-dts/shallowMount.d-test.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ let wrapper = shallowMount(AppWithDefine, {
2121
// vm is properly typed
2222
expectType<string>(wrapper.vm.a)
2323

24-
// // can not receive extra props
25-
// expectError(
26-
// shallowMount(AppWithDefine, {
27-
// props: { a: 'Hello', c: 2 }
28-
// })
29-
// )
24+
// allow extra props, like using `h()`
25+
shallowMount(AppWithDefine, {
26+
props: { a: 'Hello', c: 2 }
27+
})
3028

3129
// wrong prop type should not compile
3230
expectError(
@@ -53,12 +51,10 @@ expectType<string>(
5351
}).vm.a
5452
)
5553

56-
// // can't receive extra props
57-
// expectError(
58-
// shallowMount(AppWithProps, {
59-
// props: { a: 'Hello', b: 2 }
60-
// })
61-
// )
54+
// allow extra props, like using `h()`
55+
shallowMount(AppWithProps, {
56+
props: { a: 'Hello', b: 2 }
57+
})
6258

6359
// wrong prop type should not compile
6460
expectError(

0 commit comments

Comments
 (0)