wip(compiler-ssr): v-html, v-text & textarea value
This commit is contained in:
52
packages/compiler-ssr/__tests__/ssrElement.spec.ts
Normal file
52
packages/compiler-ssr/__tests__/ssrElement.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { getCompiledString } from './utils'
|
||||
|
||||
describe('element', () => {
|
||||
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(
|
||||
`"\`<div>\${interpolate(_ctx.foo)}</div>\`"`
|
||||
)
|
||||
})
|
||||
|
||||
test('<textarea> with dynamic value', () => {
|
||||
expect(getCompiledString(`<textarea :value="foo"/>`)).toMatchInlineSnapshot(
|
||||
`"\`<textarea>\${interpolate(_ctx.foo)}</textarea>\`"`
|
||||
)
|
||||
})
|
||||
|
||||
test('<textarea> with static value', () => {
|
||||
expect(
|
||||
getCompiledString(`<textarea value="fo>o"/>`)
|
||||
).toMatchInlineSnapshot(`"\`<textarea>fo>o</textarea>\`"`)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user