Skip to content

Commit

Permalink
fix: Add props to stubs for built-in components
Browse files Browse the repository at this point in the history
Signed-off-by: Wolfgang Walther <[email protected]>
  • Loading branch information
wolfgangwalther committed Sep 13, 2022
1 parent 41f77b3 commit 0de4bb4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
36 changes: 33 additions & 3 deletions src/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,28 @@ export function stubComponents(
return [
createStub({
name: 'transition',
type: {
props: [
'name',
'css',
'type',
'duration',
'mode',
'appear',
'enterFromClass',
'enterActiveClass',
'enterToClass',
'appearFromClass',
'appearActiveClass',
'appearToClass',
'leaveFromClass',
'leaveActiveClass',
'leaveToClass'
]
},
renderStubDefaultSlot: true
}),
undefined,
props,
children
]
}
Expand All @@ -185,9 +204,15 @@ export function stubComponents(
return [
createStub({
name: 'transition-group',
type: {
props: [
'tag',
'moveClass'
]
},
renderStubDefaultSlot: true
}),
undefined,
props,
children
]
}
Expand All @@ -199,9 +224,14 @@ export function stubComponents(
return [
createStub({
name: 'teleport',
type: {
props: [
'disabled'
]
},
renderStubDefaultSlot: true
}),
undefined,
props,
() => children
]
}
Expand Down
21 changes: 15 additions & 6 deletions tests/features/transition.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
)
})
})
2 changes: 1 addition & 1 deletion tests/mountingOptions/global.stubs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ describe('mounting options: stubs', () => {
})

expect(wrapper.html()).toBe(
'<teleport-stub>\n' +
'<teleport-stub to="body">\n' +
' <div id="content"></div>\n' +
'</teleport-stub>'
)
Expand Down

0 comments on commit 0de4bb4

Please sign in to comment.