import { describe, it, expect } from "vitest"; import { render, screen } from "@testing-library/react"; import { RegularSeasonStandings } from "../RegularSeasonStandings"; function makeRow(overrides: Partial<{ id: string; participantId: string; wins: number; losses: number; otLosses: number | null; gamesPlayed: number; winPct: string | null; gamesBack: string | null; conference: string | null; division: string | null; conferenceRank: number | null; divisionRank: number | null; leagueRank: number | null; streak: string | null; lastTen: string | null; homeRecord: string | null; awayRecord: string | null; syncedAt: string | null; participant: { id: string; name: string; shortName?: string | null }; }> = {}) { return { id: overrides.id ?? "row-1", participantId: overrides.participantId ?? "p-1", wins: overrides.wins ?? 40, losses: overrides.losses ?? 28, otLosses: overrides.otLosses ?? null, gamesPlayed: overrides.gamesPlayed ?? 68, winPct: overrides.winPct ?? "0.5882", gamesBack: overrides.gamesBack ?? null, conference: overrides.conference ?? null, division: overrides.division ?? null, conferenceRank: overrides.conferenceRank ?? null, divisionRank: overrides.divisionRank ?? null, leagueRank: overrides.leagueRank ?? 1, streak: overrides.streak ?? null, lastTen: overrides.lastTen ?? null, homeRecord: overrides.homeRecord ?? null, awayRecord: overrides.awayRecord ?? null, syncedAt: overrides.syncedAt ?? null, participant: overrides.participant ?? { id: "p-1", name: "Boston Celtics" }, }; } const NO_OWNERSHIPS = {}; const NO_USER_IDS: string[] = []; describe("RegularSeasonStandings", () => { it("renders nothing when standings array is empty", () => { const { container } = render( ); expect(container.firstChild).toBeNull(); }); it("renders team names", () => { render( ); expect(screen.getByText("Boston Celtics")).toBeInTheDocument(); expect(screen.getByText("Toronto Raptors")).toBeInTheDocument(); }); it("shows OTL column when showOtLosses=true", () => { render( ); expect(screen.getByText("OTL")).toBeInTheDocument(); }); it("hides OTL column when showOtLosses=false (default)", () => { render( ); expect(screen.queryByText("OTL")).not.toBeInTheDocument(); }); it("renders conference headings and inline division labels when present", () => { render( ); // Conference group headings are rendered as

expect(screen.getByText(/Eastern Conference/i)).toBeInTheDocument(); expect(screen.getByText(/Western Conference/i)).toBeInTheDocument(); // Division is now shown as an inline label per row (not a section header) expect(screen.getAllByText(/Atlantic/i).length).toBeGreaterThan(0); expect(screen.getAllByText(/Pacific/i).length).toBeGreaterThan(0); }); it("shows ownership badge for drafted teams", () => { render( ); expect(screen.getByText("Alice")).toBeInTheDocument(); }); it("does not show badge for undrafted teams", () => { render( ); // No owner badge should be present expect(screen.queryByText(/Alice/i)).not.toBeInTheDocument(); }); it("applies different styling for user's own team", () => { const { container } = render( ); // The user's row should have a primary styling class const userRow = container.querySelector("tr.bg-primary\\/5"); expect(userRow).not.toBeNull(); }); it("renders streak with correct color class for wins", () => { render( ); const streakEl = screen.getByText("W5"); expect(streakEl.className).toContain("emerald"); }); it("renders streak with destructive class for losses", () => { render( ); const streakEl = screen.getByText("L3"); expect(streakEl.className).toContain("destructive"); }); });