1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/packages/utils/markdown.test.ts

56 lines
975 B
TypeScript
Raw Normal View History

import { extractUrls } from './markdown';
import { Link } from './types';
describe('markdown', () => {
test.each([
[
'',
[],
],
[
'Some text and no links',
[],
],
[
'[](https://example.com)',
[
{
url: 'https://example.com',
title: '',
},
],
],
[
'before [testing](https://example.com) [testing **with bold**](https://example2.com) after',
[
{
url: 'https://example.com',
title: 'testing',
},
{
url: 'https://example2.com',
title: 'testing with bold',
},
],
],
[
'[Testing MD](https://example.com/md) <a href="https://example.com/html">Testing HTML</a>',
[
{
url: 'https://example.com/md',
title: 'Testing MD',
},
{
url: 'https://example.com/html',
title: 'Testing HTML',
},
],
],
])('should extract URLs', (md: string, expected: Link[]) => {
const actual = extractUrls(md);
expect(actual).toEqual(expected);
});
});