-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathindex.test.ts
More file actions
165 lines (126 loc) · 5.53 KB
/
Copy pathindex.test.ts
File metadata and controls
165 lines (126 loc) · 5.53 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import html, { render } from '@bbob/html'
import core from '@bbob/core'
import preset from '../src'
const parse = (input: string) => {
const tree = core(preset()).process(input, { render })
return html(input, preset())
};
describe('@bbob/preset-html5', () => {
test('[b]bolded text[/b]', () => {
const input = '[b]bolded text[/b]';
const result = '<span style="font-weight: bold;">bolded text</span>';
expect(parse(input)).toBe(result);
});
test('[i]italicized text[/i]', () => {
const input = '[i]italicized text[/i]';
const result = '<span style="font-style: italic;">italicized text</span>';
expect(parse(input)).toBe(result);
});
test('[u]underlined text[/u]', () => {
const input = '[u]underlined text[/u]';
const result = '<span style="text-decoration: underline;">underlined text</span>';
expect(parse(input)).toBe(result);
});
test('[s]strikethrough text[/s]', () => {
const input = '[s]strikethrough text[/s]';
const result = '<span style="text-decoration: line-through;">strikethrough text</span>';
expect(parse(input)).toBe(result);
});
test('[url]https://en.wikipedia.org[/url]', () => {
const input = '[url]https://en.wikipedia.org[/url]';
const result = '<a href="https://en.wikipedia.org">https://en.wikipedia.org</a>';
expect(parse(input)).toBe(result);
});
test('[url=http://step.pgc.edu/]ECAT[/url]', () => {
const input = '[url=http://step.pgc.edu/]ECAT[/url]';
const result = '<a href="http://step.pgc.edu/">ECAT</a>';
expect(parse(input)).toBe(result);
});
test('[img]https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Go-home-2.svg/100px-Go-home-2.svg.png[/img]', () => {
const input = '[img]https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Go-home-2.svg/100px-Go-home-2.svg.png[/img]';
const result = '<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Go-home-2.svg/100px-Go-home-2.svg.png"/>';
expect(parse(input)).toBe(result);
});
test('[img]https://tw.greywool.com/i/e3Ph5.png[/img]', () => {
const input = '[img]https://tw.greywool.com/i/e3Ph5.png[/img]';
const result = '<img src="https://tw.greywool.com/i/e3Ph5.png"/>';
expect(parse(input)).toBe(result);
});
test('[img width="100" height="50" alt="Lubeck city gate" title="This is one of the medieval city gates of Lubeck"]https://www.bbcode.org/images/lubeck_small.jpg[/img]', () => {
const input = '[img width="100" height="50" alt="Lubeck city gate" title="This is one of the medieval city gates of Lubeck"]https://www.bbcode.org/images/lubeck_small.jpg[/img]';
const result = '<img width="100" height="50" alt="Lubeck city gate" title="This is one of the medieval city gates of Lubeck" src="https://www.bbcode.org/images/lubeck_small.jpg"/>';
expect(parse(input)).toBe(result);
});
test('[quote="author"]quoted text[/quote]', () => {
const input = '[quote="author"]quoted text[/quote]';
const result = '<blockquote><p>quoted text</p></blockquote>';
expect(parse(input)).toBe(result);
});
test('[code]monospaced text[/code]', () => {
const input = '[code]monospaced text[/code]';
const result = '<pre>monospaced text</pre>';
expect(parse(input)).toBe(result);
});
test('[style size="15px"]Large Text[/style]', () => {
const input = '[style size="15px"]Large Text[/style]';
const result = '<span style="font-size:15px;">Large Text</span>';
expect(parse(input)).toBe(result);
});
test('[style color="red"]Red Text[/style]', () => {
const input = '[style color="red"]Red Text[/style]';
const result = '<span style="color:red;">Red Text</span>';
expect(parse(input)).toBe(result);
});
test('[color="red"]Red Text[/color]', () => {
const input = '[color="red"]Red Text[/color]';
const result = '<span style="color: red;">Red Text</span>';
expect(parse(input)).toBe(result);
});
test(`[list][*]Entry 1[/list]`, () => {
const input = `[list][*]Entry 1[*]Entry 2[/list]`;
const result = '<ul><li>Entry 1</li><li>Entry 2</li></ul>';
expect(parse(input)).toBe(result);
});
test(`[list]*Entry 1[/list]`, () => {
const input = `
[list]
*Entry 1
*Entry 2
[/list]`;
const result = `
<ul>
<li>Entry 1
</li><li>Entry 2
</li></ul>`;
expect(parse(input)).toBe(result);
});
test('[list=1][/list]', () => {
const input = `[list=1][/list]`;
const result = `<ol type="1"></ol>`;
expect(parse(input)).toBe(result);
});
test('[list=A][/list]', () => {
const input = `[list=A][/list]`;
const result = `<ol type="A"></ol>`;
expect(parse(input)).toBe(result);
});
test('[spoiler]hidden text[/spoiler]', () => {
const input = '[spoiler]hidden text[/spoiler]';
const result = '<span class="bb-spoiler" style="background-color: #000; color: transparent;">hidden text</span>';
});
test('[size=20]test 20[/size]', () => {
const input = '[size=20]test 20[/size]';
const result = '<span style="font-size: 2em;">test 20</span>';
expect(parse(input)).toBe(result);
});
test('[size=15]test 15[/size]', () => {
const input = '[size=15]test 15[/size]';
const result = '<span style="font-size: 1.5em;">test 15</span>';
expect(parse(input)).toBe(result);
});
test(`[table][/table]`, () => {
const input = `[table][tr][td]table 1[/td][td]table 2[/td][/tr][tr][td]table 3[/td][td]table 4[/td][/tr][/table]`;
const result = `<table><tr><td>table 1</td><td>table 2</td></tr><tr><td>table 3</td><td>table 4</td></tr></table>`;
expect(parse(input)).toBe(result);
});
});