2020-03-11 04:52:08 +08:00
|
|
|
import { compile } from '../src'
|
|
|
|
|
|
|
|
describe('ssr compile: suspense', () => {
|
|
|
|
test('implicit default', () => {
|
|
|
|
expect(compile(`<suspense><foo/></suspense>`).code).toMatchInlineSnapshot(`
|
2020-03-16 23:23:29 +08:00
|
|
|
"const { resolveComponent: _resolveComponent, withCtx: _withCtx } = require(\\"vue\\")
|
2020-03-11 04:52:08 +08:00
|
|
|
const { ssrRenderComponent: _ssrRenderComponent, ssrRenderSuspense: _ssrRenderSuspense } = require(\\"@vue/server-renderer\\")
|
|
|
|
|
2020-06-27 02:23:50 +08:00
|
|
|
return function ssrRender(_ctx, _push, _parent, _attrs) {
|
2020-03-11 04:52:08 +08:00
|
|
|
const _component_foo = _resolveComponent(\\"foo\\")
|
|
|
|
|
2020-03-17 03:38:35 +08:00
|
|
|
_ssrRenderSuspense(_push, {
|
|
|
|
default: () => {
|
2020-03-11 04:52:08 +08:00
|
|
|
_push(_ssrRenderComponent(_component_foo, null, null, _parent))
|
|
|
|
},
|
2020-12-01 04:11:58 +08:00
|
|
|
_: 1 /* STABLE */
|
2020-03-17 03:38:35 +08:00
|
|
|
})
|
2020-03-11 04:52:08 +08:00
|
|
|
}"
|
|
|
|
`)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('explicit slots', () => {
|
|
|
|
expect(
|
|
|
|
compile(`<suspense>
|
|
|
|
<template #default>
|
|
|
|
<foo/>
|
|
|
|
</template>
|
|
|
|
<template #fallback>
|
|
|
|
loading...
|
|
|
|
</template>
|
|
|
|
</suspense>`).code
|
|
|
|
).toMatchInlineSnapshot(`
|
2020-03-16 23:23:29 +08:00
|
|
|
"const { resolveComponent: _resolveComponent, withCtx: _withCtx } = require(\\"vue\\")
|
2020-03-11 04:52:08 +08:00
|
|
|
const { ssrRenderComponent: _ssrRenderComponent, ssrRenderSuspense: _ssrRenderSuspense } = require(\\"@vue/server-renderer\\")
|
|
|
|
|
2020-06-27 02:23:50 +08:00
|
|
|
return function ssrRender(_ctx, _push, _parent, _attrs) {
|
2020-03-11 04:52:08 +08:00
|
|
|
const _component_foo = _resolveComponent(\\"foo\\")
|
|
|
|
|
2020-03-17 03:38:35 +08:00
|
|
|
_ssrRenderSuspense(_push, {
|
|
|
|
default: () => {
|
2020-03-11 04:52:08 +08:00
|
|
|
_push(_ssrRenderComponent(_component_foo, null, null, _parent))
|
|
|
|
},
|
2020-03-17 03:38:35 +08:00
|
|
|
fallback: () => {
|
2020-03-11 04:52:08 +08:00
|
|
|
_push(\` loading... \`)
|
|
|
|
},
|
2020-12-01 04:11:58 +08:00
|
|
|
_: 1 /* STABLE */
|
2020-03-17 03:38:35 +08:00
|
|
|
})
|
2020-03-11 04:52:08 +08:00
|
|
|
}"
|
|
|
|
`)
|
|
|
|
})
|
|
|
|
})
|