import { getCompiledString } from './utils' import { compile } from '../src' describe('ssr: element', () => { test('basic elements', () => { expect(getCompiledString(`
`)).toMatchInlineSnapshot( `"\`
\`"` ) expect(getCompiledString(`
`)).toMatchInlineSnapshot( `"\`
\`"` ) }) test('nested elements', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot(`"\`
\`"`) }) test('void element', () => { expect(getCompiledString(``)).toMatchInlineSnapshot(`"\`\`"`) }) describe('children override', () => { test('v-html', () => { expect(getCompiledString(`
`)).toMatchInlineSnapshot( `"\`
\${_ctx.foo}
\`"` ) }) test('v-text', () => { expect(getCompiledString(`
`)).toMatchInlineSnapshot( `"\`
\${_ssrInterpolate(_ctx.foo)}
\`"` ) }) test('\`"` ) }) test('\`"`) }) test('`).code) .toMatchInlineSnapshot(` "const { ssrRenderAttrs: _ssrRenderAttrs, ssrInterpolate: _ssrInterpolate } = require(\\"@vue/server-renderer\\") return function ssrRender(_ctx, _push, _parent) { let _temp0 _push(\`\${ _ssrInterpolate((\\"value\\" in _temp0) ? _temp0.value : \\"fallback\\") }\`) }" `) }) }) describe('attrs', () => { test('static attrs', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot(`"\`
\`"`) }) test('v-bind:class', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`
\`"` ) }) test('static class + v-bind:class', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`
\`"` ) }) test('v-bind:style', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`
\`"` ) }) test('static style + v-bind:style', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`
\`"` ) }) test('v-bind:key (boolean)', () => { expect( getCompiledString(``) ).toMatchInlineSnapshot( `"\`\`"` ) }) test('v-bind:key (non-boolean)', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`
\`"` ) }) test('v-bind:[key]', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`
\`"` ) expect(getCompiledString(`
`)) .toMatchInlineSnapshot(` "\`
\`" `) expect(getCompiledString(`
`)) .toMatchInlineSnapshot(` "\`\`" `) }) test('v-bind="obj"', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot(`"\`\`"`) expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`\`"` ) expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`\`"` ) // dynamic key + v-bind="object" expect( getCompiledString(`
`) ).toMatchInlineSnapshot( `"\`\`"` ) // should merge class and :class expect(getCompiledString(`
`)) .toMatchInlineSnapshot(` "\`\`" `) // should merge style and :style expect( getCompiledString( `
` ) ).toMatchInlineSnapshot(` "\`\`" `) }) test('should ignore v-on', () => { expect( getCompiledString(`
`) ).toMatchInlineSnapshot(`"\`
\`"`) expect( getCompiledString(`
`) ).toMatchInlineSnapshot(`"\`
\`"`) expect( getCompiledString(`
`) ).toMatchInlineSnapshot(`"\`
\`"`) }) }) })