// @vitest-environment jsdom
import { describe, expect, it } from "vitest";
import { toHtml } from "./NoteEditor";
describe("toHtml sanitization (M15/THREAT-006)", () => {
// Plain text path — escape special chars when no tag-like content present.
it("escapes plain text ampersand", () => {
expect(toHtml("a & b")).toBe("a & b");
});
it("converts newlines to
in plain text", () => {
expect(toHtml("line1\nline2")).toBe("line1
line2");
});
// Strips disallowed tags by replacing with their textContent.
it("strips iframe", () => {
expect(toHtml('')).not.toContain("iframe");
});
it("strips base", () => {
expect(toHtml('')).not.toContain("base");
});
it("strips meta refresh", () => {
expect(toHtml('')).not.toContain("meta");
});
it("strips form", () => {
expect(toHtml('
')).not.toContain("form");
});
it("strips script", () => {
expect(toHtml('')).not.toContain("script");
});
it("strips style", () => {
expect(toHtml('')).not.toContain("style");
});
it("strips object/embed", () => {
expect(toHtml('')).not.toContain("object");
expect(toHtml('