import { describe, expect, it } from "vitest"; import { htmlToText, quoteText, replySubject, textToHtml } from "../text"; describe("text helpers", () => { it("linkifies and escapes", () => { const html = textToHtml("see now"); expect(html).toContain("<"); expect(html).toContain(' { expect(textToHtml("> hi\n>> there")).toContain('class="q1"'); expect(textToHtml("> hi\n>> there")).toContain('class="q2"'); }); it("converts html to text", () => { const t = htmlToText("

Hello world

q
link"); expect(t).toContain("Hello world"); expect(t).toContain("- one"); expect(t).toContain("> q"); expect(t).toContain("link "); }); it("quotes and subjects", () => { expect(quoteText("a\n> b")).toBe("> a\n>> b"); expect(replySubject("Re: Hi", "Re")).toBe("Re: Hi"); expect(replySubject("Fwd: Hi", "Re")).toBe("Re: Hi"); expect(replySubject("Hi", "Fwd")).toBe("Fwd: Hi"); }); });