From a4aa277dbb79fbbfc963a36f8a548773fa1c93b6 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 13 Sep 2022 11:26:14 +0200 Subject: [PATCH] fix: Add props to stubs for built-in components Signed-off-by: Wolfgang Walther --- src/stubs.ts | 9 ++++++--- tests/features/transition.spec.ts | 21 +++++++++++++++------ tests/mountingOptions/global.stubs.spec.ts | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/stubs.ts b/src/stubs.ts index f4bf0a12f..be74b38d7 100644 --- a/src/stubs.ts +++ b/src/stubs.ts @@ -171,9 +171,10 @@ export function stubComponents( return [ createStub({ name: 'transition', + type: type as any, renderStubDefaultSlot: true }), - undefined, + props, children ] } @@ -185,9 +186,10 @@ export function stubComponents( return [ createStub({ name: 'transition-group', + type: type as any, renderStubDefaultSlot: true }), - undefined, + props, children ] } @@ -199,9 +201,10 @@ export function stubComponents( return [ createStub({ name: 'teleport', + type: type as any, renderStubDefaultSlot: true }), - undefined, + props, () => children ] } diff --git a/tests/features/transition.spec.ts b/tests/features/transition.spec.ts index 3c813ae8f..11b63527e 100644 --- a/tests/features/transition.spec.ts +++ b/tests/features/transition.spec.ts @@ -1,11 +1,20 @@ -import { expect, test } from 'vitest' +import { describe, expect, test } from 'vitest' import { WithTransition } from '../components/WithTransition' import { mount } from '../../src' -test('works with transitions', async () => { - const wrapper = mount(WithTransition) - expect(wrapper.find('#message').exists()).toBe(false) +describe('transitions', () => { + test('work', async () => { + const wrapper = mount(WithTransition) + expect(wrapper.find('#message').exists()).toBe(false) - await wrapper.find('button').trigger('click') - expect(wrapper.find('#message').exists()).toBe(true) + await wrapper.find('button').trigger('click') + expect(wrapper.find('#message').exists()).toBe(true) + }) + + test('have props', () => { + const wrapper = mount(WithTransition) + expect(wrapper.getComponent({ name: 'transition' }).props('name')).toBe( + 'fade' + ) + }) }) diff --git a/tests/mountingOptions/global.stubs.spec.ts b/tests/mountingOptions/global.stubs.spec.ts index c97f51038..403911eab 100644 --- a/tests/mountingOptions/global.stubs.spec.ts +++ b/tests/mountingOptions/global.stubs.spec.ts @@ -401,7 +401,7 @@ describe('mounting options: stubs', () => { const wrapper = mount(CompStubbedByDefault) expect(wrapper.html()).toBe( - '\n' + + '\n' + '
\n' + '
' ) @@ -513,7 +513,7 @@ describe('mounting options: stubs', () => { }) expect(wrapper.html()).toBe( - '\n' + + '\n' + '
\n' + '
' )