/
html.test.ts
72 lines (63 loc) · 2.24 KB
/
html.test.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { split, HTML } from './html'
test('utility/html.split', () => {
const LOREM_IPSU = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.`
expect(split('', 0)).toEqual([''])
expect(split(LOREM_IPSU, 1)).toEqual(LOREM_IPSU.split(' '))
expect(split(LOREM_IPSU, 10)).toEqual([
"Lorem Ipsum",
"is simply dummy",
"text of the",
"printing and",
"typesetting",
"industry. Lorem",
"Ipsum has been",
"the industry's",
"standard dummy",
"text ever since",
"the 1500s,",
"when an unknown",
"printer took",
"a galley of",
"type and scrambled",
"it to make",
"a type specimen",
"book.",
])
expect(split(LOREM_IPSU, 100)).toEqual([
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's",
"standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled",
"it to make a type specimen book.",
])
})
describe('lib/utility/html#HTML', () => {
test('.code', () => {
const html = new HTML
expect(html.code('CODE')).toBe('<code class="highlight"><table class="code"><tbody>CODE</tbody></table></code>')
})
test('.highlight', () => {
const html = new HTML
expect(html.highlight('CODE')).toBe('<strong>CODE</strong>')
})
test('.sup', () => {
const html = new HTML
expect(html.sup('CODE')).toBe(' <sup>CODE</sup>')
})
test('.line', () => {
const html = new HTML
expect(html.index).toBe(1)
expect(html.line('CODE')).toBe('<tr class="row"><td id="L1" class="td-index">1</td><td id="LC1" class="td-code">CODE</td></tr>')
expect(html.index).toBe(2)
})
test('.tab', () => {
const html = new HTML
expect(html.tab('CODE')).toBe('<span class="tab">CODE</span>')
})
test('.keyword', () => {
const html = new HTML
expect(html.keyword('CODE')).toBe('<span class="keyword operator ts">CODE</span>')
})
test('.comment', () => {
const html = new HTML
expect(html.comment('CODE')).toBe('<span class="comment line"># CODE</span>')
})
})