-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstrings.test.js
36 lines (33 loc) · 1.32 KB
/
strings.test.js
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
const strings = require("./strings");
test("should escape special HTML characters", () => {
expect(
strings.escapeHtml(`>>> Ben & Nuts sont "fous" l'un de l'autre <3`)
).toBe(">>> Ben & Nuts sont \"fous\" l'un de l'autre <3");
});
test("should capitalize speaker name", () => {
expect(strings.capitalize("john doe")).toBe("John Doe");
expect(strings.capitalize("JANE DOE")).toBe("Jane Doe");
expect(strings.capitalize("jOHn DOe")).toBe("John Doe");
expect(strings.capitalize("Jane-john doe")).toBe("Jane-John Doe");
});
test("should convert markdown format", () => {
expect(strings.formatMarkdown("Some **bold** text here")).toBe(
"Some *bold* text here"
);
expect(strings.formatMarkdown("Some _italic_ text here")).toBe(
"Some _italic_ text here"
);
expect(strings.formatMarkdown("Some **_bold and italic_** text here")).toBe(
"Some *_bold and italic_* text here"
);
expect(strings.formatMarkdown("Some _**italic and bold**_ text here")).toBe(
"Some _*italic and bold*_ text here"
);
expect(
strings.formatMarkdown("Newline after.<br>Another new line after.</br>")
).toBe("Newline after.\\nAnother new line after.\\n");
expect(strings.formatMarkdown("<b>some bold text</b>")).toBe(
"*some bold text*"
);
expect(strings.formatMarkdown("<MyComponent/>")).toBe("<MyComponent>");
});