withScopeId,
resolveComponent,
ComponentOptions,
- Portal,
ref,
defineComponent
} from 'vue'
import { escapeHtml, mockWarn } from '@vue/shared'
-import {
- renderToString,
- renderComponent,
- SSRContext
-} from '../src/renderToString'
+import { renderToString, renderComponent } from '../src/renderToString'
import { ssrRenderSlot } from '../src/helpers/ssrRenderSlot'
mockWarn()
})
})
- test('portal', async () => {
- const ctx: SSRContext = {}
- await renderToString(
- h(
- Portal,
- {
- target: `#target`
- },
- h('span', 'hello')
- ),
- ctx
- )
- expect(ctx.portals!['#target']).toBe('<span>hello</span>')
- })
-
describe('scopeId', () => {
// note: here we are only testing scopeId handling for vdom serialization.
// compiled srr render functions will include scopeId directly in strings.
-import { createApp } from 'vue'
+import { createApp, h, Portal } from 'vue'
import { renderToString, SSRContext } from '../src/renderToString'
import { ssrRenderPortal } from '../src/helpers/ssrRenderPortal'
describe('ssrRenderPortal', () => {
- test('portal rendering', async () => {
+ test('portal rendering (compiled)', async () => {
const ctx = {
portals: {}
} as SSRContext
)
expect(ctx.portals!['#target']).toBe(`<div>content</div>`)
})
+
+ test('portal rendering (vnode)', async () => {
+ const ctx: SSRContext = {}
+ await renderToString(
+ h(
+ Portal,
+ {
+ target: `#target`
+ },
+ h('span', 'hello')
+ ),
+ ctx
+ )
+ expect(ctx.portals!['#target']).toBe('<span>hello</span>')
+ })
})