import { describe, it, expect } from "vitest"; import { extractHtml } from "../extract-html.js"; describe("extractHtml", () => { it('returns "" for agent error text ("rate limit exceeded")', () => { expect(extractHtml("rate limit exceeded")).toBe(""); }); it('returns "" for empty string input', () => { expect(extractHtml("")).toBe(""); }); it('returns "" for plain text without HTML markers ("Here is your result: some text")', () => { expect(extractHtml("Here is your result: some text")).toBe(""); }); it('returns "" for non-HTML fenced code block (```json {"a":1} ```)', () => { expect(extractHtml('```json\n{"a":1}\n```')).toBe(""); }); it("extracts DOCTYPE + full HTML from text with surrounding content", () => { const input = "Sure!\n
ok"; expect(extractHtml(input)).toBe("ok"); }); it("extracts inner content from fenced HTML code block", () => { const input = "```html\nok\n```"; expect(extractHtml(input)).toBe("ok"); }); it("returns content starting with < that is valid HTML snippet", () => { const input = "Hello
Hello