forked from melloware/react-logviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.test.ts
More file actions
43 lines (40 loc) · 1.2 KB
/
utils.test.ts
File metadata and controls
43 lines (40 loc) · 1.2 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
import { parseLinks } from "./utils";
describe("Parsing lines with links", () => {
it("should be able to parse links wrapped in parentheses.", () => {
const lines = [
{
text: "(https://example.com)",
},
];
const links = parseLinks(lines);
expect(links.length).toBe(4);
expect(links[0]?.text).toBeFalsy();
expect(links[1]?.text).toBe("(");
expect(links[2]?.text?.endsWith(")")).toBeFalsy();
expect(links[3]?.text).toBe(")");
});
it("should be able to parse links starting with a parenthesis.", () => {
const lines = [
{
text: "(https://example.com",
},
];
const links = parseLinks(lines);
expect(links.length).toBe(3);
expect(links[0]?.text).toBeFalsy();
expect(links[1]?.text).toBe("(");
expect(links[2]?.text?.endsWith(")")).toBeFalsy();
});
it("should be able to parse links with a trailing parenthesis.", () => {
const lines = [
{
text: "https://example.com)",
},
];
const links = parseLinks(lines);
expect(links.length).toBe(3);
expect(links[0]?.text).toBeFalsy();
expect(links[1]?.text?.endsWith(")")).toBeFalsy();
expect(links[2]?.text).toBe(")");
});
});