import { createApp, createVNode } from 'vue'
import { renderToString } from '../src/renderToString'
describe('ssr: dynamic component', () => {
test('resolved to component', async () => {
expect(
await renderToString(
createApp({
components: {
one: {
template: `
`
}
},
template: `slot`
})
)
).toBe(`slot
`)
})
test('resolve to element', async () => {
expect(
await renderToString(
createApp({
template: `slot`
})
)
).toBe(`slot
`)
})
test('resolve to component vnode', async () => {
const Child = {
props: ['id'],
template: `{{ id }}
`
}
expect(
await renderToString(
createApp({
setup() {
return {
vnode: createVNode(Child, { id: 'test' })
}
},
template: `slot`
})
)
).toBe(`testslot
`)
})
test('resolve to element vnode', async () => {
expect(
await renderToString(
createApp({
setup() {
return {
vnode: createVNode('div', { id: 'test' })
}
},
template: `slot`
})
)
).toBe(`slot
`)
})
})