-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(shared): add test case for escapeHtmlComment (#8065)
- Loading branch information
1 parent
f01afda
commit fa65cb6
Showing
1 changed file
with
30 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
import { escapeHtml } from '../src' | ||
|
||
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>`) | ||
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) | ||
}) | ||
}) |