From 70c2d5bbc066585febd12536a6ab39c4384b277b Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 17 May 2022 11:13:22 +0800 Subject: [PATCH] fix(ssr): fix ssr render output for fragment in slots fix #5859 --- .../server-renderer/__tests__/ssrSlot.spec.ts | 86 +++++++++++++++++++ .../src/helpers/ssrRenderSlot.ts | 4 +- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 packages/server-renderer/__tests__/ssrSlot.spec.ts diff --git a/packages/server-renderer/__tests__/ssrSlot.spec.ts b/packages/server-renderer/__tests__/ssrSlot.spec.ts new file mode 100644 index 00000000..a68569ca --- /dev/null +++ b/packages/server-renderer/__tests__/ssrSlot.spec.ts @@ -0,0 +1,86 @@ +/** + * @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(`
hi
`) + }) + + test('empty slot', async () => { + expect( + await renderToString( + createApp({ + components: { + one: { + template: `
` + } + }, + template: `