vue3-core/packages/server-renderer/__tests__/ssrInterpolate.spec.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
643 B
TypeScript
Raw Permalink Normal View History

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