|
9 | 9 | ref,
|
10 | 10 | SetupContext,
|
11 | 11 | Prop,
|
12 |
| - VNodeChild |
| 12 | + VNodeChild, |
| 13 | + SlotsType, |
| 14 | + VNode |
13 | 15 | } from 'vue'
|
14 | 16 | import { Options, Vue } from 'vue-class-component'
|
15 | 17 | import { mount } from '../src'
|
@@ -340,3 +342,82 @@ expectError(
|
340 | 342 | }
|
341 | 343 | )
|
342 | 344 | )
|
| 345 | + |
| 346 | +// slots |
| 347 | +const SetupComponentWithSlots = defineComponent< |
| 348 | + { |
| 349 | + hello: string |
| 350 | + }, |
| 351 | + { |
| 352 | + hallo: () => void |
| 353 | + }, |
| 354 | + string, |
| 355 | + SlotsType<{ |
| 356 | + foo: () => VNode[] |
| 357 | + bar: () => VNode[] |
| 358 | + baz: () => VNode[] |
| 359 | + }> |
| 360 | +>((): any => {}) |
| 361 | + |
| 362 | +// optional slots |
| 363 | +mount(SetupComponentWithSlots, {}) |
| 364 | + |
| 365 | +mount(SetupComponentWithSlots, { |
| 366 | + slots: {} |
| 367 | +}) |
| 368 | + |
| 369 | +mount(SetupComponentWithSlots, { |
| 370 | + slots: { |
| 371 | + foo: 'foo' |
| 372 | + } |
| 373 | +}) |
| 374 | + |
| 375 | +mount(SetupComponentWithSlots, { |
| 376 | + slots: { |
| 377 | + foo: 'foo', |
| 378 | + bar: 'bar' |
| 379 | + } |
| 380 | +}) |
| 381 | + |
| 382 | +mount(SetupComponentWithSlots, { |
| 383 | + slots: { |
| 384 | + foo: 'foo', |
| 385 | + bar: 'bar', |
| 386 | + baz: 'baz' |
| 387 | + } |
| 388 | +}) |
| 389 | + |
| 390 | +// extra slots |
| 391 | +mount(SetupComponentWithSlots, { |
| 392 | + slots: { |
| 393 | + // @ts-expect-error - This slot doesn't exist in the component and it should be reported. |
| 394 | + extraSlot: 'nonExistentSlot' |
| 395 | + } |
| 396 | +}) |
| 397 | + |
| 398 | +mount(SetupComponentWithSlots, { |
| 399 | + slots: { |
| 400 | + foo: 'foo', |
| 401 | + // @ts-expect-error - This slot doesn't exist in the component and it should be reported. |
| 402 | + extraSlot: 'nonExistentSlot' |
| 403 | + } |
| 404 | +}) |
| 405 | + |
| 406 | +mount(SetupComponentWithSlots, { |
| 407 | + slots: { |
| 408 | + foo: 'foo', |
| 409 | + bar: 'bar', |
| 410 | + // @ts-expect-error - This slot doesn't exist in the component and it should be reported. |
| 411 | + extraSlot: 'nonExistentSlot' |
| 412 | + } |
| 413 | +}) |
| 414 | + |
| 415 | +mount(SetupComponentWithSlots, { |
| 416 | + slots: { |
| 417 | + foo: 'foo', |
| 418 | + bar: 'bar', |
| 419 | + baz: 'baz', |
| 420 | + // @ts-expect-error - This slot doesn't exist in the component and it should be reported. |
| 421 | + extraSlot: 'nonExistentSlot' |
| 422 | + } |
| 423 | +}) |
0 commit comments