Skip to content

Commit 6a99a32

Browse files
committed
test: move test to shared dir
1 parent 69a473c commit 6a99a32

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed
Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { decodeHtmlEntities, toIsoDateString } from '../../../../app/utils/formatters'
2+
import { toIsoDateString } from '../../../../app/utils/formatters'
33

44
describe('toIsoDateString', () => {
55
it('formats a date as YYYY-MM-DD', () => {
@@ -10,29 +10,3 @@ describe('toIsoDateString', () => {
1010
expect(toIsoDateString(new Date('2024-01-05T00:00:00Z'))).toBe('2024-01-05')
1111
})
1212
})
13-
14-
describe('decodeHtmlEntities', () => {
15-
it.each([
16-
['&', '&'],
17-
['&lt;', '<'],
18-
['&gt;', '>'],
19-
['&quot;', '"'],
20-
['&#39;', "'"],
21-
['&apos;', "'"],
22-
['&nbsp;', ' '],
23-
] as const)('%s → %s', (input, expected) => {
24-
expect(decodeHtmlEntities(input)).toBe(expected)
25-
})
26-
27-
it('decodes multiple entities in one string', () => {
28-
expect(decodeHtmlEntities('a &amp; b &lt; c')).toBe('a & b < c')
29-
})
30-
31-
it('leaves plain text unchanged', () => {
32-
expect(decodeHtmlEntities('say no to bloat')).toBe('say no to bloat')
33-
})
34-
35-
it('leaves unknown entities unchanged', () => {
36-
expect(decodeHtmlEntities('&unknown;')).toBe('&unknown;')
37-
})
38-
})
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { decodeHtmlEntities } from '../../../../shared/utils/html'
3+
4+
describe('decodeHtmlEntities', () => {
5+
it.each([
6+
['&amp;', '&'],
7+
['&lt;', '<'],
8+
['&gt;', '>'],
9+
['&quot;', '"'],
10+
['&#39;', "'"],
11+
['&apos;', "'"],
12+
['&nbsp;', ' '],
13+
] as const)('%s → %s', (input, expected) => {
14+
expect(decodeHtmlEntities(input)).toBe(expected)
15+
})
16+
17+
it('decodes multiple entities in one string', () => {
18+
expect(decodeHtmlEntities('a &amp; b &lt; c')).toBe('a & b < c')
19+
})
20+
21+
it('leaves plain text unchanged', () => {
22+
expect(decodeHtmlEntities('say no to bloat')).toBe('say no to bloat')
23+
})
24+
25+
it('leaves unknown entities unchanged', () => {
26+
expect(decodeHtmlEntities('&unknown;')).toBe('&unknown;')
27+
})
28+
})

0 commit comments

Comments
 (0)