Some text with a link
Section
Text with bold and emphasis
- Item 1
- Item 2 with link
import { extractLinks, extractMetadata, transformHtml, } from "../html-transformer"; describe("HTML Transformer", () => { describe("extractLinks", () => { it("should return empty array for null or undefined input", async () => { expect(await extractLinks(null)).toEqual([]); expect(await extractLinks(undefined)).toEqual([]); }); it("should extract links from HTML content", async () => { const html = `
Example Test `; const links = await extractLinks(html); expect(links).toContain("https://example.com"); expect(links).toContain("https://test.com"); }); it("should handle relative links", async () => { const html = ` Relative Parent Path Local Path Implicit Relative Query Param Hash Link `; const links = await extractLinks(html); expect(links).toEqual([ "/path/to/page", "../another/page", "./local/page", "relative/path", "?param=value", "#section", ]); }); it("should handle complex nested HTML structure", async () => { const html = `Some text with a link
Test
Remove me");
expect(result).not.toContain("");
});
it("should handle complex content filtering", async () => {
const options = {
html: `
Important content Important content Real content Real content © 2024 <tag> Special chars: á é í ó ú ñ Emojis: 🎉 👍 🚀Title
Title
");
expect(result).toContain("