47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { renderReactEmail } from "../render-helpers.js";
|
|
import { BaseLayout } from "./BaseLayout.js";
|
|
import { Footer } from "./Footer.js";
|
|
import { defaultMailBrand, withBrandDefaults } from "./theme.js";
|
|
|
|
describe("Footer platform-link contract", () => {
|
|
test("keeps every platform legal link when overrides try to remove them", () => {
|
|
const brand = withBrandDefaults({ privacyUrl: undefined, termsUrl: undefined, imprintUrl: undefined });
|
|
const { html } = renderReactEmail(<Footer brand={brand} unsubscribeUrl="https://app.example.com/unsubscribe?token=abc" />);
|
|
|
|
expect(html).toContain(">Privacy<");
|
|
expect(html).toContain(">Terms<");
|
|
expect(html).toContain(">Imprint<");
|
|
expect(html).toContain(">Unsubscribe<");
|
|
expect(html).toContain('href="https://app.example.com/unsubscribe?token=abc"');
|
|
// The support contact line is always rendered.
|
|
expect(html).toContain(`mailto:${brand.supportEmail}`);
|
|
});
|
|
|
|
test("keeps terms and imprint when a partial override tries to remove them", () => {
|
|
const brand = withBrandDefaults({ termsUrl: undefined, imprintUrl: undefined });
|
|
const { html } = renderReactEmail(<Footer brand={brand} />);
|
|
|
|
expect(html).toContain(">Privacy<");
|
|
expect(html).toContain(">Terms<");
|
|
expect(html).toContain(">Imprint<");
|
|
expect(html).toContain(">·<");
|
|
// No unsubscribe link when none was supplied.
|
|
expect(html).not.toContain(">Unsubscribe<");
|
|
});
|
|
});
|
|
|
|
describe("BaseLayout preview-text branch", () => {
|
|
test("omits the hidden preview div when no previewText is supplied", () => {
|
|
const { html } = renderReactEmail(
|
|
<BaseLayout brand={defaultMailBrand} title="No preview">
|
|
<p>Body</p>
|
|
</BaseLayout>
|
|
);
|
|
|
|
// The preview snippet container uses a 1px font-size — it must be absent here.
|
|
expect(html).not.toContain("font-size:1px");
|
|
expect(html).toContain("Body");
|
|
});
|
|
});
|