-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
autolinking.test.js
43 lines (37 loc) · 1.21 KB
/
autolinking.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
37
38
39
40
41
42
43
import { renderMarkdown } from '../dist/index.js';
import chai from 'chai';
import { mockRenderMarkdownParams } from './test-utils.js';
describe('autolinking', () => {
describe('plain md', () => {
it('autolinks URLs starting with a protocol in plain text', async () => {
const { code } = await renderMarkdown(
`See https://example.com for more.`,
mockRenderMarkdownParams
);
chai
.expect(code.replace(/\n/g, ''))
.to.equal(`<p>See <a href="https://example.com">https://example.com</a> for more.</p>`);
});
it('autolinks URLs starting with "www." in plain text', async () => {
const { code } = await renderMarkdown(
`See www.example.com for more.`,
mockRenderMarkdownParams
);
chai
.expect(code.trim())
.to.equal(`<p>See <a href="http://www.example.com">www.example.com</a> for more.</p>`);
});
it('does not autolink URLs in code blocks', async () => {
const { code } = await renderMarkdown(
'See `https://example.com` or `www.example.com` for more.',
mockRenderMarkdownParams
);
chai
.expect(code.trim())
.to.equal(
`<p>See <code>https://example.com</code> or ` +
`<code>www.example.com</code> for more.</p>`
);
});
});
});