generated from kawarimidoll/deno-dev-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
marked_test.ts
52 lines (46 loc) · 2.1 KB
/
marked_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
import { assertEquals } from "./deps.ts";
import { Marked } from "./marked.ts";
Deno.test("[Marked] header", () => {
assertEquals(
Marked.parse("# header 1").content,
`<h1 id="header-1">header 1</h1>`,
);
});
Deno.test("[Marked] image", () => {
assertEquals(
Marked.parse("![image](image.png)").content,
`<p><figure><img src="image.png" alt="image" loading="lazy"></figure></p>` +
"\n",
);
});
Deno.test("[Marked] external link", () => {
assertEquals(
Marked.parse("[GitHub](https://github.com)").content,
`<p><a href="https://github.com" target="_blank" rel="noopener noreferrer">GitHub<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="feather"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg></a></p>` +
"\n",
);
});
Deno.test("[Marked] normal text", () => {
assertEquals(
Marked.parse("github.com").content,
`<p>github.com</p>` + "\n",
);
});
Deno.test("[Marked] auto link", () => {
assertEquals(
Marked.parse("https://github.com").content,
`<p><a href="https://github.com" target="_blank" rel="noopener noreferrer">https://github.com<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="feather"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg></a></p>` +
"\n",
);
assertEquals(
Marked.parse("http://www.example.com").content,
`<p><a href="http://www.example.com" target="_blank" rel="noopener noreferrer">http://www.example.com<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="feather"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg></a></p>` +
"\n",
);
});
Deno.test("[Marked] ignore auto link", () => {
assertEquals(
Marked.parse("`https://github.com`").content,
`<p><code>https://github.com</code></p>` + "\n",
);
});