Skip to content

Commit

Permalink
repro: vuejs#1973
Browse files Browse the repository at this point in the history
  • Loading branch information
cexbrayat committed Feb 11, 2023
1 parent 264909a commit 3a7fd02
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ export function mount<
>
>
// component declared by vue-tsc ScriptSetup
export function mount<T extends DefineComponent<any, any, any, any, any>>(
export function mount<
T extends DefineComponent<any, any, any, any, any, any, any, any, any>
>(
component: T,
options?: ComponentMountingOptions<T>
): VueWrapper<InstanceType<T>>
Expand Down
15 changes: 15 additions & 0 deletions tests/components/DefinePropsAndDefineEmits.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div :class="placement">
<slot />
</div>
</template>

<script lang="ts" setup>
defineProps<{
placement: 'start' | 'end' | 'top' | 'bottom';
}>();
defineEmits<{
(e: 'update', value: string): void;
}>();
</script>
12 changes: 12 additions & 0 deletions tests/mount.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest'
import { defineComponent } from 'vue'
import { mount } from '../src'
import DefinePropsAndDefineEmits from './components/DefinePropsAndDefineEmits.vue'
import HelloFromVitestPlayground from './components/HelloFromVitestPlayground.vue'

describe('mount: general tests', () => {
Expand Down Expand Up @@ -32,4 +33,15 @@ describe('mount: general tests', () => {

expect(spy).not.toHaveBeenCalled()
})

it('should mount a component with props, emits and slot (#1973)', () => {
const wrapper = mount(DefinePropsAndDefineEmits, {
props: {
placement: 'end'
},
slots: { default: 'Hello' }
})
expect(wrapper.get('div').text()).toContain('Hello')
expect(wrapper.get('div').classes()).toContain('end')
})
})

0 comments on commit 3a7fd02

Please sign in to comment.