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