-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathhtml.spec.ts
More file actions
28 lines (24 loc) · 790 Bytes
/
html.spec.ts
File metadata and controls
28 lines (24 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { describe, expect, it } from 'vitest'
import { decodeHtmlEntities } from '../../../../shared/utils/html'
describe('decodeHtmlEntities', () => {
it.each([
['&', '&'],
['<', '<'],
['>', '>'],
['"', '"'],
[''', "'"],
[''', "'"],
[' ', ' '],
] as const)('%s → %s', (input, expected) => {
expect(decodeHtmlEntities(input)).toBe(expected)
})
it('decodes multiple entities in one string', () => {
expect(decodeHtmlEntities('a & b < c')).toBe('a & b < c')
})
it('leaves plain text unchanged', () => {
expect(decodeHtmlEntities('say no to bloat')).toBe('say no to bloat')
})
it('leaves unknown entities unchanged', () => {
expect(decodeHtmlEntities('&unknown;')).toBe('&unknown;')
})
})