feat(compiler-ssr): compile portal (#775)
This commit is contained in:
committed by
GitHub
parent
312513d255
commit
d8ed0e7fbf
29
packages/server-renderer/__tests__/ssrRenderPortal.spec.ts
Normal file
29
packages/server-renderer/__tests__/ssrRenderPortal.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createApp } from 'vue'
|
||||
import { renderToString, SSRContext } from '../src/renderToString'
|
||||
import { ssrRenderPortal } from '../src/helpers/ssrRenderPortal'
|
||||
|
||||
describe('ssrRenderPortal', () => {
|
||||
test('portal rendering', async () => {
|
||||
const ctx = {
|
||||
portals: {}
|
||||
} as SSRContext
|
||||
await renderToString(
|
||||
createApp({
|
||||
data() {
|
||||
return { msg: 'hello' }
|
||||
},
|
||||
ssrRender(_ctx, _push, _parent) {
|
||||
ssrRenderPortal(
|
||||
_push => {
|
||||
_push(`<div>content</div>`)
|
||||
},
|
||||
'#target',
|
||||
_parent
|
||||
)
|
||||
}
|
||||
}),
|
||||
ctx
|
||||
)
|
||||
expect(ctx.portals!['#target']).toBe(`<div>content</div>`)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user