import { describe, it, expect } from "vitest";
import { htmlToPlainText } from "./html-to-plain-text";

describe("htmlToPlainText", () => {
  it("extracts visible text from HTML tags", () => {
    const html = "<p>Olá <strong>mundo</strong></p>";
    expect(htmlToPlainText(html)).toBe("Olá mundo");
  });

  it("collapses repeated spaces/tabs into a single space", () => {
    const html = "<p>Olá     mundo</p>";
    expect(htmlToPlainText(html)).toBe("Olá mundo");
  });

  it("collapses 3+ consecutive line breaks down to a double line break", () => {
    const html = "<p>Primeiro</p><br/><br/><br/><p>Segundo</p>";
    const result = htmlToPlainText(html);
    expect(result).not.toMatch(/\n{3,}/);
  });
});
