import { getHtmlLinks } from "./get-html-links.function";
import { parse as htmlParser } from 'node-html-parser';
describe('getHtmlLinks', () => {
it('correctly grabs all links in a html document', () => {
const html = htmlParser(`
link3
Invalid a tag
`);
expect(getHtmlLinks(html)).toEqual([
'http://example.com',
'http://example.com/link2',
'http://example.com/link3',
'http://example.com/link4'
])
});
it('returns an empty array if no valid links are found', () => {
const html = htmlParser(`
link3
Invalid a tag
`);
expect(getHtmlLinks(html)).toEqual([])
});
})