Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/mail/src/templates-react/_layout/layout-branches.coverage.test.tsx
T
2026-07-08 16:15:37 +02:00

50 lines
2.1 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 legal-link branches", () => {
test("renders no legal links and shows an unsubscribe link when legal URLs are absent", () => {
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).not.toContain(">Privacy<");
expect(html).not.toContain(">Terms<");
expect(html).not.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("renders only the privacy link (no separators) when terms and imprint are absent", () => {
const brand = withBrandDefaults({ termsUrl: undefined, imprintUrl: undefined });
const { html } = renderReactEmail(<Footer brand={brand} />);
expect(html).toContain(">Privacy<");
expect(html).not.toContain(">Terms<");
expect(html).not.toContain(">Imprint<");
// No middot separator should be emitted when only one legal link exists.
expect(html).not.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");
});
});