fix: ensure vnode hooks are called consistently regardless of keep-alive

This commit is contained in:
Evan You
2020-07-01 19:50:04 -04:00
parent c9629f2692
commit 4e8e689572
3 changed files with 63 additions and 33 deletions

View File

@@ -567,7 +567,7 @@ describe('KeepAlive', () => {
})
})
it('should not call onVnodeUnmounted', async () => {
it('should call correct vnode hooks', async () => {
const Foo = markRaw({
name: 'Foo',
render() {
@@ -643,14 +643,16 @@ describe('KeepAlive', () => {
await nextTick()
expect(spyMounted).toHaveBeenCalledTimes(2)
expect(spyUnmounted).toHaveBeenCalledTimes(0)
expect(spyUnmounted).toHaveBeenCalledTimes(1)
toggle()
await nextTick()
expect(spyMounted).toHaveBeenCalledTimes(3)
expect(spyUnmounted).toHaveBeenCalledTimes(2)
render(null, root)
await nextTick()
expect(spyMounted).toHaveBeenCalledTimes(2)
expect(spyUnmounted).toHaveBeenCalledTimes(2)
expect(spyMounted).toHaveBeenCalledTimes(3)
expect(spyUnmounted).toHaveBeenCalledTimes(4)
})
})