import test from "node:test"; import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { dirname, join } from "node:path"; import { MAILTO_TARGET, buildContactMailto, handleContactSubmit, readFormValues, } from "../js/contact.js"; const root = join(dirname(fileURLToPath(import.meta.url)), ".."); const contactHtml = readFileSync(join(root, "contact.html"), "utf8"); const indexHtml = readFileSync(join(root, "index.html"), "utf8"); /** Minimal stand-in for a DOM form (has querySelectorAll("[name]")). */ function fakeForm(values) { return { querySelectorAll(selector) { assert.equal(selector, "[name]"); return Object.entries(values).map(([name, value]) => ({ name, value })); }, }; } // --------------------------------------------------------------------------- // Component tests: the contact page renders the three required fields // --------------------------------------------------------------------------- test("contact page renders a form with name, email, and message fields", () => { assert.match(contactHtml, /