Files
Reactive-Resume/apps/web/src/components/ui/copyright.test.tsx
T
Amruth Pillai f8767c32f1 refactor(ui): retire the shadcn colour aliases
Every class that used the old names (muted, primary, card, border, input and the rest) now uses the Desk & Paper token it resolved to, with text colours on their text tokens (accent-text, danger-text, ink-3). The compatibility block in the theme is gone.
2026-09-29 00:56:59 +02:00

57 lines
1.8 KiB
TypeScript

// @vitest-environment happy-dom
import { render, screen } from "@testing-library/react";
import { beforeAll, describe, expect, it, vi } from "vitest";
import { i18n } from "@lingui/core";
import { I18nProvider } from "@lingui/react";
vi.stubGlobal("__APP_VERSION__", "9.9.9");
const { Copyright } = await import("./copyright");
beforeAll(() => {
i18n.loadAndActivate({ locale: "en", messages: {} });
});
const renderCopyright = (props?: React.ComponentProps<typeof Copyright>) =>
render(
<I18nProvider i18n={i18n}>
<Copyright {...props} />
</I18nProvider>,
);
describe("Copyright", () => {
it("renders the MIT license link", () => {
renderCopyright();
const link = screen.getByRole("link", { name: "MIT" });
expect(link.getAttribute("href")).toBe("https://github.com/reactive-resume/reactive-resume/blob/main/LICENSE");
expect(link.getAttribute("rel")).toBe("noopener noreferrer");
});
it("renders the Amruth Pillai attribution link", () => {
renderCopyright();
const link = screen.getByRole("link", { name: "Amruth Pillai" });
expect(link.getAttribute("href")).toBe("https://amruthpillai.com");
});
it("includes the app version string", () => {
renderCopyright();
// The version is wrapped in <bdi> for RTL isolation, so it is its own text node.
expect(screen.getByText("9.9.9")).toBeInTheDocument();
});
it("merges custom className into the wrapper", () => {
const { container } = renderCopyright({ className: "extra-class" });
const wrapper = container.firstChild as HTMLElement;
expect(wrapper.className).toContain("extra-class");
expect(wrapper.className).toContain("text-ink-3");
});
it("opens external links in a new tab", () => {
renderCopyright();
for (const link of screen.getAllByRole("link")) {
expect(link.getAttribute("target")).toBe("_blank");
}
});
});