29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { renderReactEmail } from "../render-helpers.js";
|
|
import { defaultMailBrand } from "../_layout/theme.js";
|
|
import { InvalidActionUrlError } from "../_layout/Button.js";
|
|
import { MagicLinkEmail } from "./MagicLink.js";
|
|
|
|
describe("MagicLinkEmail", () => {
|
|
test("renders default snapshot", () => {
|
|
const result = renderReactEmail(
|
|
<MagicLinkEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/magic/abc" />
|
|
);
|
|
expect(result.html).toMatchSnapshot("html");
|
|
expect(result.text).toMatchSnapshot("text");
|
|
});
|
|
|
|
test("emits expiry InfoBox copy", () => {
|
|
const { html } = renderReactEmail(
|
|
<MagicLinkEmail brand={defaultMailBrand} actionUrl="https://app.example.com/magic/abc" expiresInMinutes={10} />
|
|
);
|
|
expect(html).toContain("expires in 10 minutes");
|
|
});
|
|
|
|
test("rejects javascript: action URL", () => {
|
|
expect(() =>
|
|
renderReactEmail(<MagicLinkEmail brand={defaultMailBrand} actionUrl="javascript:alert(1)" />)
|
|
).toThrow(InvalidActionUrlError);
|
|
});
|
|
});
|