import { compile } from '../src' const scopeId = 'data-v-xxxxxxx' describe('ssr: scopeId', () => { test('basic', () => { expect( compile(`
hello
`, { scopeId }).code ).toMatchInlineSnapshot(` " return function ssrRender(_ctx, _push, _parent) { _push(\`
hello
\`) }" `) }) test('inside slots (only text)', () => { // should have no branching inside slot expect( compile(`foo`, { scopeId }).code ).toMatchInlineSnapshot(` "const { resolveComponent } = require(\\"vue\\") const { _ssrRenderComponent } = require(\\"@vue/server-renderer\\") return function ssrRender(_ctx, _push, _parent) { const _component_foo = resolveComponent(\\"foo\\") _push(_ssrRenderComponent(_component_foo, null, { default: (_, _push, _parent, _scopeId) => { _push(\`foo\`) }, _compiled: true }, _parent)) }" `) }) test('inside slots (with elements)', () => { expect( compile(`hello`, { scopeId }).code ).toMatchInlineSnapshot(` "const { resolveComponent } = require(\\"vue\\") const { _ssrRenderComponent } = require(\\"@vue/server-renderer\\") return function ssrRender(_ctx, _push, _parent) { const _component_foo = resolveComponent(\\"foo\\") _push(_ssrRenderComponent(_component_foo, null, { default: (_, _push, _parent, _scopeId) => { if (_scopeId) { _push(\`hello\`) } else { _push(\`hello\`) } }, _compiled: true }, _parent)) }" `) }) test('nested slots', () => { expect( compile(`hello`, { scopeId }).code ).toMatchInlineSnapshot(` "const { resolveComponent } = require(\\"vue\\") const { _ssrRenderComponent } = require(\\"@vue/server-renderer\\") return function ssrRender(_ctx, _push, _parent) { const _component_bar = resolveComponent(\\"bar\\") const _component_foo = resolveComponent(\\"foo\\") _push(_ssrRenderComponent(_component_foo, null, { default: (_, _push, _parent, _scopeId) => { if (_scopeId) { _push(\`hello\`) _push(_ssrRenderComponent(_component_bar, null, { default: (_, _push, _parent, _scopeId) => { if (_scopeId) { _push(\`\`) } else { _push(\`\`) } }, _compiled: true }, _parent)) } else { _push(\`hello\`) _push(_ssrRenderComponent(_component_bar, null, { default: (_, _push, _parent, _scopeId) => { if (_scopeId) { _push(\`\`) } else { _push(\`\`) } }, _compiled: true }, _parent)) } }, _compiled: true }, _parent)) }" `) }) })