calcom/test/lib/emails/invitation.test.ts
Mihai C 8d6fec79d3
feat: add translations for emails and type error fixes overall (#994)
* feat: add translations for forgot password email and misc

* fix: type fixes

* feat: translate invitation email

* fix: e2e tests

* fix: lint

* feat: type fixes and i18n for emails

* Merge main

* fix: jest import on server path

* Merge

* fix: playwright tests

* fix: lint

Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
2021-10-25 14:05:21 +01:00

27 lines
1 KiB
TypeScript

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("<p>hello world</p><br /><div>welcome to the brave <span>new</span> 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(
`<br />${t("user_invited_you", { user: invitation.from, teamName: invitation.teamName })}<br />`
);
expect(result).toContain("/auth/signup?token=invite-token&");
expect(result).toContain(`${t("request_another_invitation_email", { toEmail: invitation.toEmail })}`);
});