Skip to content

Commit 659c0bf

Browse files
committed
test: add test case
1 parent 12fef2d commit 659c0bf

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createApp } from 'vue'
1+
import { createApp, defineAsyncComponent, h } from 'vue'
22
import { renderToString } from '../src/renderToString'
33

44
const components = {
@@ -154,6 +154,38 @@ describe('ssr: slot', () => {
154154
).toBe(`<div><p>1</p><p>2</p></div>`)
155155
})
156156

157+
// #12438
158+
test('async component slot with v-if true', async () => {
159+
const Layout = defineAsyncComponent(() =>
160+
Promise.resolve({
161+
template: `<div><slot name="header">default header</slot></div>`,
162+
}),
163+
)
164+
const LayoutLoader = {
165+
setup(_: any, context: any) {
166+
return () => h(Layout, {}, context.slots)
167+
},
168+
}
169+
expect(
170+
await renderToString(
171+
createApp({
172+
components: {
173+
LayoutLoader,
174+
},
175+
template: `
176+
<Suspense>
177+
<LayoutLoader>
178+
<template v-if="true" #header>
179+
new header
180+
</template>
181+
</LayoutLoader>
182+
</Suspense>
183+
`,
184+
}),
185+
),
186+
).toBe(`<div><!--[--> new header <!--]--></div>`)
187+
})
188+
157189
// #11326
158190
test('dynamic component slot', async () => {
159191
expect(

0 commit comments

Comments
 (0)