import { expect, it } from "@jest/globals";
import { html, text, Invitation } from "@lib/emails/invitation";
import { getTranslation } from "@server/lib/i18n";
it("email text rendering should strip tags and add new lines", () => {
const result = text("
hello world
welcome to the brave new world");
expect(result).toEqual("hello world\nwelcome to the brave new world");
});
it("email html should render invite email", async () => {
const t = await getTranslation("en", "common");
const invitation = {
language: t,
from: "Huxley",
toEmail: "hello@example.com",
teamName: "Calendar Lovers",
token: "invite-token",
} as Invitation;
const result = html(invitation);
expect(result).toContain(
`
${t("user_invited_you", { user: invitation.from, teamName: invitation.teamName })}
`
);
expect(result).toContain("/auth/signup?token=invite-token&");
expect(result).toContain(`${t("request_another_invitation_email", { toEmail: invitation.toEmail })}`);
});