Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
import { describe, expect, it } from "@suaveplan/testing/runner";
import { findFirst, textOf } from "../../../tests/setup/html.js";
import { renderToHtml } from "../../renderer/renderer.js";
import { renderVNode } from "../../vnode/vnode.js";
import { VerificationEmail, verificationTemplate } from "./verification.js";
describe("verificationTemplate", () => {
it("renders verification code", { timeout: 5000 }, () => {
const { html } = renderToHtml(verificationTemplate, {
recipientName: "Jane",
verificationUrl: "https://x/verify",
code: "ABC123",
});
const p = findFirst(
html,
(el) => el.name === "p" && textOf(el).includes("ABC123")
);
expect(p).not.toBeNull();
});
it("omits code block when code not supplied", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
})
);
expect(html).not.toContain("letter-spacing:8px");
});
it("omits code block for empty string code", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
code: "",
})
);
expect(html).not.toContain("letter-spacing:8px");
});
it("renders expiry notice with custom minutes", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
expiresInMinutes: 5,
})
);
expect(html).toContain("5 minutes");
});
it("uses default 30 minute expiry when omitted", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
})
);
expect(html).toContain("30 minutes");
});
it("uses companyName fallback to theme.branding", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
})
);
// default theme companyName = "Company"
expect(html).toContain("Company registration");
});
it("uses explicit companyName", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
companyName: "Acme",
})
);
expect(html).toContain("Acme registration");
});
it("exposes a literal subject", { timeout: 5000 }, () => {
expect(verificationTemplate.subject).toBe("Verify Your Email Address");
});
it("renders the verify-email CTA", { timeout: 5000 }, () => {
const html = renderVNode(
VerificationEmail({
recipientName: "Jane",
verificationUrl: "https://x/verify",
})
);
const a = findFirst(
html,
(el) => el.name === "a" && el.attribs.href === "https://x/verify"
);
expect(a).not.toBeNull();
});
});