Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+59
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import {
|
||||
reactTransactionalTemplateNames,
|
||||
renderTransactionalEmail,
|
||||
withBrandDefaults,
|
||||
} from "./render.js";
|
||||
|
||||
const brand = withBrandDefaults();
|
||||
|
||||
describe("renderTransactionalEmail", () => {
|
||||
test("exposes all 8 template names", () => {
|
||||
const names = reactTransactionalTemplateNames();
|
||||
expect(names).toEqual([
|
||||
"welcome",
|
||||
"magic-link",
|
||||
"password-reset",
|
||||
"invitation",
|
||||
"subscription-success",
|
||||
"subscription-failed",
|
||||
"invoice-sent",
|
||||
"tenant-notification",
|
||||
]);
|
||||
});
|
||||
|
||||
test("renders welcome via dispatch", () => {
|
||||
const result = renderTransactionalEmail("welcome", {
|
||||
brand,
|
||||
recipientName: "Ada",
|
||||
actionUrl: "https://app.example.com/login",
|
||||
});
|
||||
expect(result.html).toContain("Welcome to ToolCTRL, Ada!");
|
||||
expect(result.text).toContain("Welcome to ToolCTRL, Ada!");
|
||||
});
|
||||
|
||||
test("renders invitation via dispatch", () => {
|
||||
const result = renderTransactionalEmail("invitation", {
|
||||
brand,
|
||||
senderName: "Grace",
|
||||
senderOrganization: "Example Org",
|
||||
actionUrl: "https://app.example.com/invite",
|
||||
});
|
||||
expect(result.html).toContain("Grace invited you to ToolCTRL");
|
||||
expect(result.text).toContain("Join Example Org");
|
||||
});
|
||||
|
||||
test("throws on unknown template", () => {
|
||||
expect(() =>
|
||||
renderTransactionalEmail("unknown" as Parameters<typeof renderTransactionalEmail>[0], {} as never)
|
||||
).toThrow(/Unknown React transactional template/);
|
||||
});
|
||||
|
||||
test("returns html with <!DOCTYPE html> prefix for SSR mode", () => {
|
||||
const { html } = renderTransactionalEmail("welcome", {
|
||||
brand,
|
||||
actionUrl: "https://app.example.com/login",
|
||||
});
|
||||
expect(html.startsWith("<!DOCTYPE html>")).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user