2020-02-04 00:46:14 +08:00
|
|
|
import { getCompiledString } from './utils'
|
|
|
|
|
2020-02-04 04:51:41 +08:00
|
|
|
describe('ssr: element', () => {
|
2020-02-04 00:46:14 +08:00
|
|
|
test('basic elements', () => {
|
|
|
|
expect(getCompiledString(`<div></div>`)).toMatchInlineSnapshot(
|
|
|
|
`"\`<div></div>\`"`
|
|
|
|
)
|
|
|
|
expect(getCompiledString(`<div/>`)).toMatchInlineSnapshot(
|
|
|
|
`"\`<div></div>\`"`
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('static attrs', () => {
|
|
|
|
expect(
|
|
|
|
getCompiledString(`<div id="foo" class="bar"></div>`)
|
|
|
|
).toMatchInlineSnapshot(`"\`<div id=\\"foo\\" class=\\"bar\\"></div>\`"`)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('nested elements', () => {
|
|
|
|
expect(
|
|
|
|
getCompiledString(`<div><span></span><span></span></div>`)
|
|
|
|
).toMatchInlineSnapshot(`"\`<div><span></span><span></span></div>\`"`)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('void element', () => {
|
|
|
|
expect(getCompiledString(`<input>`)).toMatchInlineSnapshot(`"\`<input>\`"`)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('v-html', () => {
|
|
|
|
expect(getCompiledString(`<div v-html="foo"/>`)).toMatchInlineSnapshot(
|
|
|
|
`"\`<div>\${_ctx.foo}</div>\`"`
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('v-text', () => {
|
|
|
|
expect(getCompiledString(`<div v-text="foo"/>`)).toMatchInlineSnapshot(
|
2020-02-04 06:47:06 +08:00
|
|
|
`"\`<div>\${_interpolate(_ctx.foo)}</div>\`"`
|
2020-02-04 00:46:14 +08:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('<textarea> with dynamic value', () => {
|
|
|
|
expect(getCompiledString(`<textarea :value="foo"/>`)).toMatchInlineSnapshot(
|
2020-02-04 06:47:06 +08:00
|
|
|
`"\`<textarea>\${_interpolate(_ctx.foo)}</textarea>\`"`
|
2020-02-04 00:46:14 +08:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('<textarea> with static value', () => {
|
|
|
|
expect(
|
|
|
|
getCompiledString(`<textarea value="fo>o"/>`)
|
|
|
|
).toMatchInlineSnapshot(`"\`<textarea>fo>o</textarea>\`"`)
|
|
|
|
})
|
|
|
|
})
|