mirror of https://github.com/vuejs/core.git
chore: add test case
This commit is contained in:
parent
d2e2a192ef
commit
4e5e0b4d49
|
@ -894,4 +894,56 @@ describe('hot module replacement', () => {
|
|||
await timeout()
|
||||
expect(serializeInner(root)).toBe('<div>bar</div>')
|
||||
})
|
||||
|
||||
test('multi reload child wrapped in Suspense + KeepAlive', async () => {
|
||||
const id = 'test-child-reload-3'
|
||||
const Child: ComponentOptions = {
|
||||
__hmrId: id,
|
||||
setup() {
|
||||
const count = ref(0)
|
||||
return { count }
|
||||
},
|
||||
render: compileToFunction(`<div>{{ count }}</div>`),
|
||||
}
|
||||
createRecord(id, Child)
|
||||
|
||||
const appId = 'test-app-id'
|
||||
const App: ComponentOptions = {
|
||||
__hmrId: appId,
|
||||
components: { Child },
|
||||
render: compileToFunction(`
|
||||
<KeepAlive>
|
||||
<Suspense>
|
||||
<Child />
|
||||
</Suspense>
|
||||
</KeepAlive>
|
||||
`),
|
||||
}
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(App), root)
|
||||
expect(serializeInner(root)).toBe('<div>0</div>')
|
||||
await timeout()
|
||||
reload(id, {
|
||||
__hmrId: id,
|
||||
setup() {
|
||||
const count = ref(1)
|
||||
return { count }
|
||||
},
|
||||
render: compileToFunction(`<div>{{ count }}</div>`),
|
||||
})
|
||||
await timeout()
|
||||
expect(serializeInner(root)).toBe('<div>1</div>')
|
||||
|
||||
reload(id, {
|
||||
__hmrId: id,
|
||||
setup() {
|
||||
const count = ref(2)
|
||||
return { count }
|
||||
},
|
||||
render: compileToFunction(`<div>{{ count }}</div>`),
|
||||
})
|
||||
await timeout()
|
||||
expect(serializeInner(root)).toBe('<div>2</div>')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -204,7 +204,7 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||
if (
|
||||
oldInnerChild &&
|
||||
oldInnerChild.type !== Comment &&
|
||||
!isSameVNodeType(innerChild, oldInnerChild) &&
|
||||
!isSameVNodeType(oldInnerChild, innerChild) &&
|
||||
recursiveGetSubtree(instance).type !== Comment
|
||||
) {
|
||||
let leavingHooks = resolveTransitionHooks(
|
||||
|
|
Loading…
Reference in New Issue