refactor(ssr): prefix ssr helpers

This commit is contained in:
Evan You
2020-02-06 12:07:25 -05:00
parent f3e70b3733
commit bc8f91d181
16 changed files with 256 additions and 136 deletions

View File

@@ -0,0 +1,29 @@
import { ssrInterpolate } from '../src/helpers/ssrInterpolate'
import { escapeHtml } from '@vue/shared'
test('ssr: interpolate', () => {
expect(ssrInterpolate(0)).toBe(`0`)
expect(ssrInterpolate(`foo`)).toBe(`foo`)
expect(ssrInterpolate(`<div>`)).toBe(`&lt;div&gt;`)
// should escape interpolated values
expect(ssrInterpolate([1, 2, 3])).toBe(
escapeHtml(JSON.stringify([1, 2, 3], null, 2))
)
expect(
ssrInterpolate({
foo: 1,
bar: `<div>`
})
).toBe(
escapeHtml(
JSON.stringify(
{
foo: 1,
bar: `<div>`
},
null,
2
)
)
)
})