import { extractUrls } from './html';
import { Link } from './types';
describe('htmlUtils', () => {
test.each([
[
'',
[],
],
[
'bla >Testing no link"',
[],
],
[
'bla Testing link"',
[
{
url: 'https://example.com',
title: 'Testing link',
},
],
],
[
'Test 1 Test 2',
[
{
url: '#',
title: 'Test 1',
},
{
url: '',
title: 'Test 2',
},
],
],
[
'',
[
{
url: 'https://example.com',
title: '',
},
],
],
[
'check & encoding',
[
{
url: '#',
title: 'check & encoding',
},
],
],
])('should retrieve links', (html: string, expected: Link[]) => {
const actual = extractUrls(html);
expect(actual).toEqual(expected);
});
});