mirror of https://github.com/vuejs/core.git
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { escapeHtml, escapeHtmlComment } from '../src'
|
|
|
|
describe('escapeHtml', () => {
|
|
test('ssr: escapeHTML', () => {
|
|
expect(escapeHtml(`foo`)).toBe(`foo`)
|
|
expect(escapeHtml(true)).toBe(`true`)
|
|
expect(escapeHtml(false)).toBe(`false`)
|
|
expect(escapeHtml(`a && b`)).toBe(`a && b`)
|
|
expect(escapeHtml(`"foo"`)).toBe(`"foo"`)
|
|
expect(escapeHtml(`'bar'`)).toBe(`'bar'`)
|
|
expect(escapeHtml(`<div>`)).toBe(`<div>`)
|
|
})
|
|
|
|
test('ssr: escapeHTMLComment', () => {
|
|
const input = '<!-- Hello --><!-- World! -->'
|
|
const result = escapeHtmlComment(input)
|
|
expect(result).toEqual(' Hello World! ')
|
|
})
|
|
|
|
test('ssr: escapeHTMLComment', () => {
|
|
const input = '<!-- Comment 1 --> Hello <!--! Comment 2 --> World!'
|
|
const result = escapeHtmlComment(input)
|
|
expect(result).toEqual(' Comment 1 Hello ! Comment 2 World!')
|
|
})
|
|
|
|
test('should not affect non-comment strings', () => {
|
|
const input = 'Hello World'
|
|
const result = escapeHtmlComment(input)
|
|
expect(result).toEqual(input)
|
|
})
|
|
})
|