blob: 126eacd9ae58631215f7837aa5dfc0dea23a67ed (
plain)
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
|
import * as md from './markdown.js';
import { expect, describe, it } from 'vitest';
describe('render', async () => {
it('renders inline links', async () => {
const markdown = `[a link](https://example.com?foo=bar)`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a href="https://example.com?foo=bar" rel="noreferrer" target="_blank">a link</a></p>
`
);
});
it('renders inline links with titles', async () => {
const markdown = `[a link](https://example.com?foo=bar "what title")`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a href="https://example.com?foo=bar" title="what title" rel="noreferrer" target="_blank">a link</a></p>
`
);
});
it('renders footnote links', async () => {
const markdown = `
[a link]
[a link]: https://example.com?foo=bar`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a href="https://example.com?foo=bar" rel="noreferrer" target="_blank">a link</a></p>
`
);
});
it('renders footnote links with titles', async () => {
const markdown = `
[a link]
[a link]: https://example.com?foo=bar "what title"`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a href="https://example.com?foo=bar" title="what title" rel="noreferrer" target="_blank">a link</a></p>
`
);
});
it('renders links with embedded markup', async () => {
const markdown = `[a _link_](https://example.com?foo=bar)`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a href="https://example.com?foo=bar" rel="noreferrer" target="_blank">a <em>link</em></a></p>
`
);
});
});
|