import { compile } from '../src' const scopeId = 'data-v-xxxxxxx' describe('ssr: scopeId', () => { test('basic', () => { expect( compile(`
hello
`, { scopeId, mode: 'module' }).code ).toMatchInlineSnapshot(` "import { withScopeId as _withScopeId } from \\"vue\\" import { ssrRenderAttrs as _ssrRenderAttrs } from \\"@vue/server-renderer\\" const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\") export const ssrRender = /*#__PURE__*/_withId(function ssrRender(_ctx, _push, _parent, _attrs) { _push(\`hello\`) })" `) }) test('inside slots (only text)', () => { // should have no branching inside slot expect( compile(`foo`, { scopeId, mode: 'module' }).code ).toMatchInlineSnapshot(` "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createTextVNode as _createTextVNode, withScopeId as _withScopeId } from \\"vue\\" import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\" const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\") export const ssrRender = /*#__PURE__*/_withId(function ssrRender(_ctx, _push, _parent, _attrs) { const _component_foo = _resolveComponent(\\"foo\\") _push(_ssrRenderComponent(_component_foo, _attrs, { default: _withId((_, _push, _parent, _scopeId) => { if (_push) { _push(\`foo\`) } else { return [ _createTextVNode(\\"foo\\") ] } }), _: 1 }, _parent)) })" `) }) test('inside slots (with elements)', () => { expect( compile(`hello`, { scopeId, mode: 'module' }).code ).toMatchInlineSnapshot(` "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, withScopeId as _withScopeId } from \\"vue\\" import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\" const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\") export const ssrRender = /*#__PURE__*/_withId(function ssrRender(_ctx, _push, _parent, _attrs) { const _component_foo = _resolveComponent(\\"foo\\") _push(_ssrRenderComponent(_component_foo, _attrs, { default: _withId((_, _push, _parent, _scopeId) => { if (_push) { _push(\`hello\`) } else { return [ _createVNode(\\"span\\", null, \\"hello\\") ] } }), _: 1 }, _parent)) })" `) }) test('nested slots', () => { expect( compile(`hello`, { scopeId, mode: 'module' }).code ).toMatchInlineSnapshot(` "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, withScopeId as _withScopeId } from \\"vue\\" import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\" const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\") export const ssrRender = /*#__PURE__*/_withId(function ssrRender(_ctx, _push, _parent, _attrs) { const _component_foo = _resolveComponent(\\"foo\\") const _component_bar = _resolveComponent(\\"bar\\") _push(_ssrRenderComponent(_component_foo, _attrs, { default: _withId((_, _push, _parent, _scopeId) => { if (_push) { _push(\`hello\`) _push(_ssrRenderComponent(_component_bar, null, { default: _withId((_, _push, _parent, _scopeId) => { if (_push) { _push(\`\`) } else { return [ _createVNode(\\"span\\") ] } }), _: 1 }, _parent)) } else { return [ _createVNode(\\"span\\", null, \\"hello\\"), _createVNode(_component_bar, null, { default: _withId(() => [ _createVNode(\\"span\\") ]), _: 1 }) ] } }), _: 1 }, _parent)) })" `) }) })