)
})
- describe.todo('transition with KeepAlive', () => {})
+ describe('transition with KeepAlive', () => {
+ test('unmount innerChild (out-in mode)', async () => {
+ const btnSelector = '.keep-alive > button'
+ const containerSelector = '.keep-alive > div'
+
+ await transitionFinish()
+ expect(await html(containerSelector)).toBe('<div>0</div>')
+
+ await click(btnSelector)
+
+ await transitionFinish()
+ expect(await html(containerSelector)).toBe('')
+ const calls = await page().evaluate(() => {
+ return (window as any).getCalls('unmount')
+ })
+ expect(calls).toStrictEqual(['TrueBranch'])
+ })
+ })
+
describe.todo('transition with Suspense', () => {})
describe.todo('transition with Teleport', () => {})
VaporTransition,
createIf,
template,
+ onUnmounted,
} from 'vue'
const show = ref(true)
const toggle = ref(true)
showLeaveCancel: [],
showAppear: [],
notEnter: [],
+
+ unmount: [],
}
window.getCalls = key => calls[key]
window.resetCalls = key => (calls[key] = [])
function changeViewInOut() {
viewInOut.value = viewInOut.value === SimpleOne ? Two : SimpleOne
}
+
+const TrueBranch = defineVaporComponent({
+ name: 'TrueBranch',
+ setup() {
+ onUnmounted(() => {
+ calls.unmount.push('TrueBranch')
+ })
+ return template('<div>0</div>')()
+ },
+})
+const includeRef = ref(['TrueBranch'])
+const click = () => {
+ toggle.value = !toggle.value
+ if (toggle.value) {
+ includeRef.value = ['TrueBranch']
+ } else {
+ includeRef.value = []
+ }
+}
</script>
<template>
</div>
<!-- mode end -->
+ <!-- with keep-alive -->
+ <div class="keep-alive">
+ <div>
+ <transition mode="out-in">
+ <KeepAlive :include="includeRef">
+ <TrueBranch v-if="toggle"></TrueBranch>
+ </KeepAlive>
+ </transition>
+ </div>
+ <button @click="click">button</button>
+ </div>
+ <!-- with keep-alive end -->
+
<!-- vdom interop -->
<div class="vdom">
<button @click="toggleVdom = !toggleVdom">toggle vdom component</button>