49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import {
|
|
theme,
|
|
renderEmail,
|
|
htmlToPlainText,
|
|
Layout,
|
|
Heading,
|
|
Paragraph,
|
|
Spacer,
|
|
Button,
|
|
Footer,
|
|
WelcomeEmail,
|
|
TrialReminderEmail,
|
|
ReActivationEmail,
|
|
GenericStepEmail,
|
|
} from "./index.js";
|
|
|
|
describe("public API barrel", () => {
|
|
it("re-exports the render helpers and theme tokens", () => {
|
|
expect(typeof renderEmail).toBe("function");
|
|
expect(typeof htmlToPlainText).toBe("function");
|
|
expect(htmlToPlainText("<p>Hello</p>")).toBe("Hello");
|
|
expect(theme.colors.primary).toBe("#2563eb");
|
|
expect(theme.containerWidth).toBe(600);
|
|
});
|
|
|
|
it("re-exports the layout and primitive components", () => {
|
|
for (const component of [Layout, Heading, Paragraph, Spacer, Button, Footer]) {
|
|
expect(typeof component).toBe("function");
|
|
}
|
|
});
|
|
|
|
it("re-exports every sequence template and renders through the barrel", () => {
|
|
for (const template of [WelcomeEmail, TrialReminderEmail, ReActivationEmail, GenericStepEmail]) {
|
|
expect(typeof template).toBe("function");
|
|
}
|
|
const { html, text } = renderEmail(
|
|
WelcomeEmail({
|
|
productName: "ToolCtrl",
|
|
ctaUrl: "https://app.example.com/onboard",
|
|
unsubscribeUrl: "https://app.example.com/unsubscribe/tok",
|
|
})
|
|
);
|
|
expect(html.startsWith("<!DOCTYPE html>")).toBe(true);
|
|
expect(html).toContain("Welcome to ToolCtrl");
|
|
expect(text).toContain("Welcome to ToolCtrl");
|
|
});
|
|
});
|