Skip to content

Commit 9c4de7b

Browse files
committed
test(srr): group portal tests
1 parent 97fb63d commit 9c4de7b

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

packages/server-renderer/__tests__/renderToString.spec.ts

+1-21
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ import {
55
withScopeId,
66
resolveComponent,
77
ComponentOptions,
8-
Portal,
98
ref,
109
defineComponent
1110
} from 'vue'
1211
import { escapeHtml, mockWarn } from '@vue/shared'
13-
import {
14-
renderToString,
15-
renderComponent,
16-
SSRContext
17-
} from '../src/renderToString'
12+
import { renderToString, renderComponent } from '../src/renderToString'
1813
import { ssrRenderSlot } from '../src/helpers/ssrRenderSlot'
1914

2015
mockWarn()
@@ -511,21 +506,6 @@ describe('ssr: renderToString', () => {
511506
})
512507
})
513508

514-
test('portal', async () => {
515-
const ctx: SSRContext = {}
516-
await renderToString(
517-
h(
518-
Portal,
519-
{
520-
target: `#target`
521-
},
522-
h('span', 'hello')
523-
),
524-
ctx
525-
)
526-
expect(ctx.portals!['#target']).toBe('<span>hello</span>')
527-
})
528-
529509
describe('scopeId', () => {
530510
// note: here we are only testing scopeId handling for vdom serialization.
531511
// compiled srr render functions will include scopeId directly in strings.

packages/server-renderer/__tests__/ssrRenderPortal.spec.ts renamed to packages/server-renderer/__tests__/ssrPortal.spec.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createApp } from 'vue'
1+
import { createApp, h, Portal } from 'vue'
22
import { renderToString, SSRContext } from '../src/renderToString'
33
import { ssrRenderPortal } from '../src/helpers/ssrRenderPortal'
44

55
describe('ssrRenderPortal', () => {
6-
test('portal rendering', async () => {
6+
test('portal rendering (compiled)', async () => {
77
const ctx = {
88
portals: {}
99
} as SSRContext
@@ -26,4 +26,19 @@ describe('ssrRenderPortal', () => {
2626
)
2727
expect(ctx.portals!['#target']).toBe(`<div>content</div>`)
2828
})
29+
30+
test('portal rendering (vnode)', async () => {
31+
const ctx: SSRContext = {}
32+
await renderToString(
33+
h(
34+
Portal,
35+
{
36+
target: `#target`
37+
},
38+
h('span', 'hello')
39+
),
40+
ctx
41+
)
42+
expect(ctx.portals!['#target']).toBe('<span>hello</span>')
43+
})
2944
})

0 commit comments

Comments
 (0)