test: update test

This commit is contained in:
Evan You 2019-09-09 17:28:35 -04:00
parent bd15138ef5
commit 0d176ebf2a

View File

@ -23,6 +23,7 @@ describe('renderer: suspense', () => {
} }
}) })
// TODO test mounted hook & watch callback buffering
const AsyncChild = createAsyncComponent( const AsyncChild = createAsyncComponent(
() => () =>
new Promise(resolve => { new Promise(resolve => {
@ -36,6 +37,19 @@ describe('renderer: suspense', () => {
}) })
) )
const AsyncChild2 = createAsyncComponent(
() =>
new Promise(resolve => {
setTimeout(() => {
resolve({
setup(props: { msg: string }) {
return () => h('div', props.msg)
}
})
}, 10)
})
)
const Mid = { const Mid = {
setup() { setup() {
return () => return () =>
@ -49,7 +63,8 @@ describe('renderer: suspense', () => {
name: 'root', name: 'root',
setup() { setup() {
// TODO test fallback // TODO test fallback
return () => h(Suspense, [msg.value, h(Mid)]) return () =>
h(Suspense, [msg.value, h(Mid), h(AsyncChild2, { msg: 'child 2' })])
} }
} }
@ -59,6 +74,16 @@ describe('renderer: suspense', () => {
await Promise.all(deps) await Promise.all(deps)
await nextTick() await nextTick()
expect(serializeInner(root)).toBe(`<!---->hello<div>hello</div><!---->`) expect(serializeInner(root)).toBe(
`<!---->hello<div>hello</div><div>child 2</div><!---->`
)
}) })
test.todo('fallback content update')
test.todo('content update before suspense resolve')
test.todo('unmount before suspense resolve')
test.todo('nested suspense')
}) })