2021-07-16 10:40:06 -04:00
|
|
|
/**
|
|
|
|
* @jest-environment node
|
|
|
|
*/
|
|
|
|
|
2020-02-06 12:07:25 -05:00
|
|
|
import { ssrInterpolate } from '../src/helpers/ssrInterpolate'
|
2020-02-03 17:47:06 -05:00
|
|
|
import { escapeHtml } from '@vue/shared'
|
2020-01-29 15:10:45 -05:00
|
|
|
|
|
|
|
test('ssr: interpolate', () => {
|
2020-02-06 12:07:25 -05:00
|
|
|
expect(ssrInterpolate(0)).toBe(`0`)
|
|
|
|
expect(ssrInterpolate(`foo`)).toBe(`foo`)
|
|
|
|
expect(ssrInterpolate(`<div>`)).toBe(`<div>`)
|
2020-01-29 15:10:45 -05:00
|
|
|
// should escape interpolated values
|
2020-02-06 12:07:25 -05:00
|
|
|
expect(ssrInterpolate([1, 2, 3])).toBe(
|
2020-01-29 15:10:45 -05:00
|
|
|
escapeHtml(JSON.stringify([1, 2, 3], null, 2))
|
|
|
|
)
|
|
|
|
expect(
|
2020-02-06 12:07:25 -05:00
|
|
|
ssrInterpolate({
|
2020-01-29 15:10:45 -05:00
|
|
|
foo: 1,
|
|
|
|
bar: `<div>`
|
|
|
|
})
|
|
|
|
).toBe(
|
|
|
|
escapeHtml(
|
|
|
|
JSON.stringify(
|
|
|
|
{
|
|
|
|
foo: 1,
|
|
|
|
bar: `<div>`
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
2
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
})
|