-
-
Notifications
You must be signed in to change notification settings - Fork 133
/
ui-spec.js
58 lines (51 loc) · 1.99 KB
/
ui-spec.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const dedent = require('dedent');
describe("Renders Markdown", () => {
describe("properly when given no opts", () => {
it("handles bold", () => {
expect(atom.ui.markdown.render("**Hello World**"))
.toBe("<p><strong>Hello World</strong></p>\n");
});
});
it(`escapes HTML in code blocks properly`, () => {
let input = dedent`
Lorem ipsum dolor.
\`\`\`html
<p>sit amet</p>
\`\`\`
`
let expected = dedent`
<p>Lorem ipsum dolor.</p>
<pre><code class="language-html"><p>sit amet</p>
</code></pre>
`
expect(
atom.ui.markdown.render(input).trim()
).toBe(expected);
})
describe("transforms links correctly", () => {
it("makes no changes to a fqdn link", () => {
expect(atom.ui.markdown.render("[Hello World](https://github.com)"))
.toBe('<p><a href="https://github.com">Hello World</a></p>\n');
});
it("resolves package links to pulsar", () => {
expect(atom.ui.markdown.render("[Hello](https://atom.io/packages/hey-pane)"))
.toBe('<p><a href="https://web.pulsar-edit.dev/packages/hey-pane">Hello</a></p>\n');
});
it("resolves atom links to web archive", () => {
expect(atom.ui.markdown.render("[Hello](https://flight-manual.atom.io/some-docs)"))
.toBe('<p><a href="https://web.archive.org/web/20221215003438/https://flight-manual.atom.io/some-docs">Hello</a></p>\n');
});
it("resolves incomplete local links", () => {
expect(atom.ui.markdown.render(
"[Hello](./readme.md)",
{ rootDomain: "https://github.com/pulsar-edit/pulsar" }
)).toBe('<p><a href="https://github.com/pulsar-edit/pulsar/blob/HEAD/readme.md">Hello</a></p>\n');
});
it("resolves incomplete root links", () => {
expect(atom.ui.markdown.render(
"[Hello](/readme.md)",
{ rootDomain: "https://github.com/pulsar-edit/pulsar" }
)).toBe('<p><a href="https://github.com/pulsar-edit/pulsar/blob/HEAD/readme.md">Hello</a></p>\n');
});
});
});