import type { ReactNode } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vitest";
import SectionItemCard from "./SectionItemCard";
vi.mock("@/components/ViewTransitionLink", () => ({
default: ({ children, to }: { children: ReactNode; to: string }) => {children},
}));
vi.mock("@/components/MediaItemMenu", () => ({
default: () => null,
}));
vi.mock("@/components/overlays/CardOverlays", () => ({
default: () => null,
}));
vi.mock("@/hooks/useOverlayPrefs", () => ({
useOverlayPrefs: () => ({ prefs: null }),
}));
describe("SectionItemCard", () => {
it("encodes item links while preserving library context", () => {
const markup = renderToStaticMarkup(
,
);
expect(markup).toContain('href="/item/ebook%201%2Fisbn%3A978?libraryId=12"');
});
it("renders episode cards with series title, episode title, and episode code", () => {
const markup = renderToStaticMarkup(
,
);
expect(markup).toContain("American Dad!");
expect(markup).toContain("Dumbston Checks In");
expect(markup).toContain("S22E10");
});
it("renders premiere metadata when an upcoming event is present", () => {
const markup = renderToStaticMarkup(
,
);
expect(markup).toContain("Series A");
expect(markup).toContain("Season Premiere");
expect(markup).toContain("Season 2 ยท Back Again");
expect(markup).toContain("Wed, Apr 8");
expect(markup).toContain("8:00 PM");
});
});