Skip to content

Commit

Permalink
feat: update Suspense usage (#2099)
Browse files Browse the repository at this point in the history
See #2099 for details.
  • Loading branch information
yyx990803 authored Sep 15, 2020
1 parent 37e686f commit 5ae7380
Show file tree
Hide file tree
Showing 17 changed files with 810 additions and 242 deletions.
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

0 comments on commit 5ae7380

Please sign in to comment.