import assert from "node:assert"; import { describe, it } from "node:test"; import { Forms } from "./index"; type TFormWithHandler = HTMLFormElement & { handler?: HTMLElement; }; describe("Forms plugin", () => { it("intercepts submit button click and stores handler", () => { document.body.innerHTML = ""; const form = document.createElement("form"); form.setAttribute("data-js-form", "{}"); const submit = document.createElement("button"); submit.setAttribute("type", "submit"); form.appendChild(submit); document.body.appendChild(form); new Forms(); submit.dispatchEvent(new window.MouseEvent("click", { bubbles: true, cancelable: true })); assert.equal((form as TFormWithHandler).handler, submit); }); });