/**
* @jest-environment node
*/
import { createApp } from 'vue'
import { renderToString } from '../src/renderToString'
const components = {
one: {
template: `
`
}
}
describe('ssr: slot', () => {
test('text slot', async () => {
expect(
await renderToString(
createApp({
components,
template: `hello`
})
)
).toBe(`hello
`)
})
test('element slot', async () => {
expect(
await renderToString(
createApp({
components,
template: `hi
`
})
)
).toBe(``)
})
test('empty slot', async () => {
expect(
await renderToString(
createApp({
components: {
one: {
template: `
`
}
},
template: ``
})
)
).toBe(``)
})
test('empty slot (manual comments)', async () => {
expect(
await renderToString(
createApp({
components: {
one: {
template: `
`
}
},
template: ``
})
)
).toBe(``)
})
test('empty slot (multi-line comments)', async () => {
expect(
await renderToString(
createApp({
components: {
one: {
template: `
`
}
},
template: ``
})
)
).toBe(``)
})
test('multiple elements', async () => {
expect(
await renderToString(
createApp({
components,
template: `one
two
`
})
)
).toBe(``)
})
test('fragment slot (template v-if)', async () => {
expect(
await renderToString(
createApp({
components,
template: `hello`
})
)
).toBe(`hello
`)
})
test('fragment slot (template v-if + multiple elements)', async () => {
expect(
await renderToString(
createApp({
components,
template: `one
two
`
})
)
).toBe(
``
)
})
test('transition slot', async () => {
expect(
await renderToString(
createApp({
components: {
one: {
template: ``
}
},
template: `foo
`
})
)
).toBe(``)
expect(
await renderToString(
createApp({
components: {
one: {
template: ``
}
},
template: `foo
`
})
)
).toBe(`foo
`)
})
})