diff options
Diffstat (limited to 'ui/lib/markdown.test.js')
| -rw-r--r-- | ui/lib/markdown.test.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ui/lib/markdown.test.js b/ui/lib/markdown.test.js new file mode 100644 index 0000000..126eacd --- /dev/null +++ b/ui/lib/markdown.test.js @@ -0,0 +1,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> +` + ); + }); +}); |
