import { describe, expect, it } from "vitest";
import { extractReadableContent } from "./web-tools.js";
const SAMPLE_HTML = `
Example Article
Example Article
Main content starts here with enough words to satisfy readability.
Second paragraph for a bit more signal.
`;
describe("web fetch readability", () => {
it("extracts readable text", async () => {
const result = await extractReadableContent({
html: SAMPLE_HTML,
url: "https://example.com/article",
extractMode: "text",
});
expect(result?.text).toContain("Main content starts here");
expect(result?.title).toBe("Example Article");
});
it("extracts readable markdown", async () => {
const result = await extractReadableContent({
html: SAMPLE_HTML,
url: "https://example.com/article",
extractMode: "markdown",
});
expect(result?.text).toContain("Main content starts here");
expect(result?.title).toBe("Example Article");
});
});