test(srr): group portal tests
This commit is contained in:
parent
97fb63d41f
commit
9c4de7b9ed
@ -5,16 +5,11 @@ import {
|
|||||||
withScopeId,
|
withScopeId,
|
||||||
resolveComponent,
|
resolveComponent,
|
||||||
ComponentOptions,
|
ComponentOptions,
|
||||||
Portal,
|
|
||||||
ref,
|
ref,
|
||||||
defineComponent
|
defineComponent
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { escapeHtml, mockWarn } from '@vue/shared'
|
import { escapeHtml, mockWarn } from '@vue/shared'
|
||||||
import {
|
import { renderToString, renderComponent } from '../src/renderToString'
|
||||||
renderToString,
|
|
||||||
renderComponent,
|
|
||||||
SSRContext
|
|
||||||
} from '../src/renderToString'
|
|
||||||
import { ssrRenderSlot } from '../src/helpers/ssrRenderSlot'
|
import { ssrRenderSlot } from '../src/helpers/ssrRenderSlot'
|
||||||
|
|
||||||
mockWarn()
|
mockWarn()
|
||||||
@ -511,21 +506,6 @@ describe('ssr: renderToString', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
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', () => {
|
describe('scopeId', () => {
|
||||||
// note: here we are only testing scopeId handling for vdom serialization.
|
// note: here we are only testing scopeId handling for vdom serialization.
|
||||||
// compiled srr render functions will include scopeId directly in strings.
|
// compiled srr render functions will include scopeId directly in strings.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp, h, Portal } from 'vue'
|
||||||
import { renderToString, SSRContext } from '../src/renderToString'
|
import { renderToString, SSRContext } from '../src/renderToString'
|
||||||
import { ssrRenderPortal } from '../src/helpers/ssrRenderPortal'
|
import { ssrRenderPortal } from '../src/helpers/ssrRenderPortal'
|
||||||
|
|
||||||
describe('ssrRenderPortal', () => {
|
describe('ssrRenderPortal', () => {
|
||||||
test('portal rendering', async () => {
|
test('portal rendering (compiled)', async () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
portals: {}
|
portals: {}
|
||||||
} as SSRContext
|
} as SSRContext
|
||||||
@ -26,4 +26,19 @@ describe('ssrRenderPortal', () => {
|
|||||||
)
|
)
|
||||||
expect(ctx.portals!['#target']).toBe(`<div>content</div>`)
|
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>')
|
||||||
|
})
|
||||||
})
|
})
|
Loading…
x
Reference in New Issue
Block a user