Skip to content

Commit f208b4f

Browse files
committed
test: add test
1 parent 49ea416 commit f208b4f

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

packages-private/vapor-e2e-test/__tests__/transition.spec.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,54 @@ describe('vapor transition', () => {
905905

906906
describe.todo('transition with KeepAlive', () => {})
907907
describe.todo('transition with Suspense', () => {})
908-
describe.todo('transition with Teleport', () => {})
908+
909+
describe('transition with Teleport', () => {
910+
test(
911+
'apply transition to teleport child',
912+
async () => {
913+
const btnSelector = '.with-teleport > button'
914+
const containerSelector = '.with-teleport > .container'
915+
const targetSelector = `.with-teleport > .target`
916+
917+
await transitionFinish()
918+
expect(await html(containerSelector)).toBe('')
919+
expect(await html(targetSelector)).toBe('')
920+
921+
// enter
922+
expect(
923+
(await transitionStart(btnSelector, `${targetSelector} div`))
924+
.classNames,
925+
).toStrictEqual(['test', 'v-enter-from', 'v-enter-active'])
926+
await nextFrame()
927+
expect(await classList(`${targetSelector} div`)).toStrictEqual([
928+
'test',
929+
'v-enter-active',
930+
'v-enter-to',
931+
])
932+
await transitionFinish()
933+
expect(await html(targetSelector)).toBe(
934+
'<div class="test">vapor compB</div>',
935+
)
936+
expect(await html(containerSelector)).toBe('')
937+
938+
// leave
939+
expect(
940+
(await transitionStart(btnSelector, `${targetSelector} div`))
941+
.classNames,
942+
).toStrictEqual(['test', 'v-leave-from', 'v-leave-active'])
943+
await nextFrame()
944+
expect(await classList(`${targetSelector} div`)).toStrictEqual([
945+
'test',
946+
'v-leave-active',
947+
'v-leave-to',
948+
])
949+
await transitionFinish()
950+
expect(await html(targetSelector)).toBe('')
951+
expect(await html(containerSelector)).toBe('')
952+
},
953+
E2E_TIMEOUT,
954+
)
955+
})
909956

910957
describe('transition with v-show', () => {
911958
test(

packages-private/vapor-e2e-test/transition/App.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
const show = ref(true)
1212
const toggle = ref(true)
1313
const count = ref(0)
14+
const hide = ref(false)
1415
1516
const timeout = (fn, time) => setTimeout(fn, time)
1617
const duration = typeof process !== 'undefined' && process.env.CI ? 200 : 50
@@ -481,6 +482,21 @@ function changeViewInOut() {
481482
</div>
482483
<!-- mode end -->
483484

485+
<!-- with teleport -->
486+
<div class="with-teleport">
487+
<div class="target"></div>
488+
<div class="container">
489+
<Transition>
490+
<Teleport to=".target" defer>
491+
<!-- comment -->
492+
<VaporCompB v-if="hide" class="test"></VaporCompB>
493+
</Teleport>
494+
</Transition>
495+
</div>
496+
<button @click="hide = !hide">button</button>
497+
</div>
498+
<!-- with teleport end -->
499+
484500
<!-- vdom interop -->
485501
<div class="vdom">
486502
<button @click="toggleVdom = !toggleVdom">toggle vdom component</button>

0 commit comments

Comments
 (0)