Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Suspense usage #2099

Merged
merged 14 commits into from
Sep 15, 2020
14 changes: 7 additions & 7 deletions packages/runtime-core/__tests__/apiAsyncComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ describe('api: defineAsyncComponent', () => {
const app = createApp({
render: () =>
h(Suspense, null, {
default: () => [h(Foo), ' & ', h(Foo)],
default: () => h('div', [h(Foo), ' & ', h(Foo)]),
fallback: () => 'loading'
})
})
Expand All @@ -416,7 +416,7 @@ describe('api: defineAsyncComponent', () => {

resolve!(() => 'resolved')
await timeout()
expect(serializeInner(root)).toBe('resolved & resolved')
expect(serializeInner(root)).toBe('<div>resolved & resolved</div>')
})

test('suspensible: false', async () => {
Expand All @@ -433,18 +433,18 @@ describe('api: defineAsyncComponent', () => {
const app = createApp({
render: () =>
h(Suspense, null, {
default: () => [h(Foo), ' & ', h(Foo)],
default: () => h('div', [h(Foo), ' & ', h(Foo)]),
fallback: () => 'loading'
})
})

app.mount(root)
// should not show suspense fallback
expect(serializeInner(root)).toBe('<!----> & <!---->')
expect(serializeInner(root)).toBe('<div><!----> & <!----></div>')

resolve!(() => 'resolved')
await timeout()
expect(serializeInner(root)).toBe('resolved & resolved')
expect(serializeInner(root)).toBe('<div>resolved & resolved</div>')
})

test('suspense with error handling', async () => {
Expand All @@ -460,7 +460,7 @@ describe('api: defineAsyncComponent', () => {
const app = createApp({
render: () =>
h(Suspense, null, {
default: () => [h(Foo), ' & ', h(Foo)],
default: () => h('div', [h(Foo), ' & ', h(Foo)]),
fallback: () => 'loading'
})
})
Expand All @@ -472,7 +472,7 @@ describe('api: defineAsyncComponent', () => {
reject!(new Error('no'))
await timeout()
expect(handler).toHaveBeenCalled()
expect(serializeInner(root)).toBe('<!----> & <!---->')
expect(serializeInner(root)).toBe('<div><!----> & <!----></div>')
})

test('retry (success)', async () => {
Expand Down
Loading