Skip to content

Commit 3a7fd02

Browse files
committed
repro: #1973
1 parent 264909a commit 3a7fd02

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/mount.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ export function mount<
203203
>
204204
>
205205
// component declared by vue-tsc ScriptSetup
206-
export function mount<T extends DefineComponent<any, any, any, any, any>>(
206+
export function mount<
207+
T extends DefineComponent<any, any, any, any, any, any, any, any, any>
208+
>(
207209
component: T,
208210
options?: ComponentMountingOptions<T>
209211
): VueWrapper<InstanceType<T>>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div :class="placement">
3+
<slot />
4+
</div>
5+
</template>
6+
7+
<script lang="ts" setup>
8+
defineProps<{
9+
placement: 'start' | 'end' | 'top' | 'bottom';
10+
}>();
11+
12+
defineEmits<{
13+
(e: 'update', value: string): void;
14+
}>();
15+
</script>

tests/mount.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it, vi } from 'vitest'
22
import { defineComponent } from 'vue'
33
import { mount } from '../src'
4+
import DefinePropsAndDefineEmits from './components/DefinePropsAndDefineEmits.vue'
45
import HelloFromVitestPlayground from './components/HelloFromVitestPlayground.vue'
56

67
describe('mount: general tests', () => {
@@ -32,4 +33,15 @@ describe('mount: general tests', () => {
3233

3334
expect(spy).not.toHaveBeenCalled()
3435
})
36+
37+
it('should mount a component with props, emits and slot (#1973)', () => {
38+
const wrapper = mount(DefinePropsAndDefineEmits, {
39+
props: {
40+
placement: 'end'
41+
},
42+
slots: { default: 'Hello' }
43+
})
44+
expect(wrapper.get('div').text()).toContain('Hello')
45+
expect(wrapper.get('div').classes()).toContain('end')
46+
})
3547
})

0 commit comments

Comments
 (0)