import { compile } from '../src'
import { getCompiledString } from './utils'
describe('ssr: text', () => {
  test('static text', () => {
    expect(getCompiledString(`foo`)).toMatchInlineSnapshot(`"\`foo\`"`)
  })
  test('static text escape', () => {
    expect(getCompiledString(`<foo>`)).toMatchInlineSnapshot(
      `"\`<foo>\`"`
    )
  })
  test('nested elements with static text', () => {
    expect(
      getCompiledString(`
hellobye
`)
    ).toMatchInlineSnapshot(
      `"\`hellobye
\`"`
    )
  })
  test('interpolation', () => {
    expect(compile(`foo {{ bar }} baz`).code).toMatchInlineSnapshot(`
      "const { _interpolate } = require(\\"@vue/server-renderer\\")
      return function ssrRender(_ctx, _push, _parent) {
        _push(\`foo \${_interpolate(_ctx.bar)} baz\`)
      }"
    `)
  })
  test('nested elements with interpolation', () => {
    expect(
      compile(`{{ foo }} barbaz {{ qux }}
`)
        .code
    ).toMatchInlineSnapshot(`
      "const { _interpolate } = require(\\"@vue/server-renderer\\")
      return function ssrRender(_ctx, _push, _parent) {
        _push(\`\${_interpolate(_ctx.foo)} barbaz \${_interpolate(_ctx.qux)}
\`)
      }"
    `)
  })
})