Skip to content

Commit fa65cb6

Browse files
test(shared): add test case for escapeHtmlComment (#8065)
1 parent f01afda commit fa65cb6

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed
Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
import { escapeHtml } from '../src'
2-
3-
test('ssr: escapeHTML', () => {
4-
expect(escapeHtml(`foo`)).toBe(`foo`)
5-
expect(escapeHtml(true)).toBe(`true`)
6-
expect(escapeHtml(false)).toBe(`false`)
7-
expect(escapeHtml(`a && b`)).toBe(`a && b`)
8-
expect(escapeHtml(`"foo"`)).toBe(`"foo"`)
9-
expect(escapeHtml(`'bar'`)).toBe(`'bar'`)
10-
expect(escapeHtml(`<div>`)).toBe(`&lt;div&gt;`)
1+
import { escapeHtml, escapeHtmlComment } from '../src'
2+
3+
describe('escapeHtml', () => {
4+
test('ssr: escapeHTML', () => {
5+
expect(escapeHtml(`foo`)).toBe(`foo`)
6+
expect(escapeHtml(true)).toBe(`true`)
7+
expect(escapeHtml(false)).toBe(`false`)
8+
expect(escapeHtml(`a && b`)).toBe(`a &amp;&amp; b`)
9+
expect(escapeHtml(`"foo"`)).toBe(`&quot;foo&quot;`)
10+
expect(escapeHtml(`'bar'`)).toBe(`&#39;bar&#39;`)
11+
expect(escapeHtml(`<div>`)).toBe(`&lt;div&gt;`)
12+
})
13+
14+
test('ssr: escapeHTMLComment', () => {
15+
const input = '<!-- Hello --><!-- World! -->'
16+
const result = escapeHtmlComment(input)
17+
expect(result).toEqual(' Hello World! ')
18+
})
19+
20+
test('ssr: escapeHTMLComment', () => {
21+
const input = '<!-- Comment 1 --> Hello <!--! Comment 2 --> World!'
22+
const result = escapeHtmlComment(input)
23+
expect(result).toEqual(' Comment 1 Hello ! Comment 2 World!')
24+
})
25+
26+
test('should not affect non-comment strings', () => {
27+
const input = 'Hello World'
28+
const result = escapeHtmlComment(input)
29+
expect(result).toEqual(input)
30+
})
1131
})

0 commit comments

Comments
 (0)