/*
RFC-0379: HTML normalizer tests — verify dynamic attribute stripping, whitespace invariance, stable hash.
- Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.
- RFC-0379: initial HTML normalizer tests.
*/
import { test, expect } from "vitest";
import { hashHtml } from "../normalizers/html.ts";
test("HTML: strips data-* attributes except data-testid", () => {
const a = hashHtml('
Hello
');
const b = hashHtml('Hello
');
expect(a).toBe(b);
});
test("HTML: strips nonce and integrity attributes", () => {
const a = hashHtml('');
const b = hashHtml('');
expect(a).toBe(b);
});
test("HTML: whitespace-invariant", () => {
const a = hashHtml("Title
");
const b = hashHtml("\n \n Title
\n \n");
expect(a).toBe(b);
});
test("HTML: strips comments", () => {
const a = hashHtml("Content
");
const b = hashHtml("Content
");
expect(a).toBe(b);
});
test("HTML: strips script and style blocks", () => {
const a = hashHtml(
"Content
",
);
const b = hashHtml("Content
");
expect(a).toBe(b);
});
test("HTML: produces stable hash for identical content", () => {
const a = hashHtml("Title
Para
");
const b = hashHtml("Title
Para
");
expect(a).toBe(b);
expect(a).toMatch(/^sha256:[0-9a-f]{64}$/);
});