fix(ssr): render components returning render function from setup (#720)

This commit is contained in:
Dmitry Sharshakov
2020-02-15 19:11:55 +03:00
committed by GitHub
parent a0163f1aa8
commit 4669215ca2
2 changed files with 31 additions and 3 deletions

View File

@@ -4,7 +4,9 @@ import {
createCommentVNode,
withScopeId,
resolveComponent,
ComponentOptions
ComponentOptions,
ref,
defineComponent
} from 'vue'
import { escapeHtml, mockWarn } from '@vue/shared'
import { renderToString, renderComponent } from '../src/renderToString'
@@ -43,6 +45,32 @@ describe('ssr: renderToString', () => {
).toBe(`<div>hello</div>`)
})
test('option components returning render from setup', async () => {
expect(
await renderToString(
createApp({
setup() {
const msg = ref('hello')
return () => h('div', msg.value)
}
})
)
).toBe(`<div>hello</div>`)
})
test('setup components returning render from setup', async () => {
expect(
await renderToString(
createApp(
defineComponent((props: {}) => {
const msg = ref('hello')
return () => h('div', msg.value)
})
)
)
).toBe(`<div>hello</div>`)
})
test('optimized components', async () => {
expect(
await renderToString(