forked from gitgitgadget/gitgitgadget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown-renderer.test.ts
More file actions
120 lines (88 loc) · 4.45 KB
/
markdown-renderer.test.ts
File metadata and controls
120 lines (88 loc) · 4.45 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* eslint-disable @stylistic/max-len */
import { expect, test } from "@jest/globals";
import { md2text } from "../lib/markdown-renderer.js";
const md = `# Welcome to GitGitGadget
A paragraph with [links](https://gitgitgadget.github.io/), with
* a
* list
* of
* items that might span more than seventy-six characters in a single item and therefore needs to be wrapped.
> Starting a block quote.
>
>> Previously quoted ipsum loren.
> Back to the base quote.`;
test("Markdown rendering test", () => {
expect(md2text(md)).toEqual(`Welcome to GitGitGadget
=======================
A paragraph with links [https://gitgitgadget.github.io/], with
* a
* list
* of
* items that might span more than seventy-six characters in a single item
and therefore needs to be wrapped.
> Starting a block quote.
>
>> Previously quoted ipsum loren.
> Back to the base quote.`);
});
test("Markdown rendering blockquote test", () => {
const bq1 = `No wrap on 75 chars
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5`;
expect(md2text(bq1)).toEqual(`No wrap on 75 chars
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5`);
const bq2 = `Exactly 76 chars should be allowed:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 90 2 4 6`;
expect(md2text(bq2)).toEqual(`Exactly 76 chars should be allowed:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 90 2 4 6`);
const bq3 = `Wrap on 77 chars:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7`;
expect(md2text(bq3)).toEqual(`Wrap on 77 chars:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
> 7`);
const bq4 = `Third level quote wrap on 77 chars:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
>>> 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7`;
expect(md2text(bq4)).toEqual(`Third level quote wrap on 77 chars:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
>
>>> 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
>>> 7`);
const bq5 = `76 - 20 = 56 levels:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 89 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7`;
expect(md2text(bq5)).toEqual(`76 - 20 = 56 levels:
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 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5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3 5 7 9 1 3 56 8 0 23 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7`;
expect(md2text(bq7)).toEqual(`Over 56 levels still has 20 char (exact):
> 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3 5 7 9 1 3 56 8 0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 23 5 7 9 1 3 5 7 9 1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3 5 7 9 1 3 5 7 9 1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3 5 7`);
});
test("task lists are rendered correctly", () => {
const taskList = `This is a task list:
* [x] done item
* [ ] item still to do`;
expect(md2text(taskList)).toEqual(`This is a task list:
* [x] done item
* [ ] item still to do`);
});