- Sort sports seasons by status (active → upcoming → completed), with
season_standings pattern last within active, then alphabetical
- Fix rank display for teams without standings: T1 when no scores exist,
T{n+1} when some teams are scored (avoids misleading T1 for unranked teams)
- Extract rank logic to getDisplayRank() in standings-display.ts with tests
- Pre-compute standingsMap and sortedTeams to eliminate O(n²) render lookups
- Fix invite URL SSR flash by deriving origin in the loader
- Guard toast useEffect with processedParamsRef to prevent double-fire
- Hide Teams Filled and Draft Order Set post-draft; show Standings sidebar
link only when active/completed
- Show "Final standings" label when season is completed
- Remove duplicate Season Status from sidebar; add Flex Spots description
- Fix status type cast to occur at the model mapping layer, not in JSX
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { getDisplayRank } from "../standings-display";
|
|
|
|
describe("getDisplayRank", () => {
|
|
describe("when the team has a standing", () => {
|
|
it("returns the numeric rank regardless of how many other teams have standings", () => {
|
|
expect(getDisplayRank({ currentRank: 1 }, 5)).toBe(1);
|
|
expect(getDisplayRank({ currentRank: 3 }, 5)).toBe(3);
|
|
});
|
|
|
|
it("returns rank 1 when the team is first", () => {
|
|
expect(getDisplayRank({ currentRank: 1 }, 1)).toBe(1);
|
|
});
|
|
});
|
|
|
|
describe("when the team has no standing and no teams have been scored yet", () => {
|
|
it("returns T1 — all teams are genuinely tied at zero", () => {
|
|
expect(getDisplayRank(undefined, 0)).toBe("T1");
|
|
});
|
|
});
|
|
|
|
describe("when the team has no standing but other teams have been scored", () => {
|
|
it("returns T{n+1} where n is the number of teams with standings", () => {
|
|
// 1 team has a standing → unranked teams are tied for 2nd
|
|
expect(getDisplayRank(undefined, 1)).toBe("T2");
|
|
|
|
// 3 teams have standings → unranked teams are tied for 4th
|
|
expect(getDisplayRank(undefined, 3)).toBe("T4");
|
|
|
|
// 9 teams have standings → unranked team is tied for 10th
|
|
expect(getDisplayRank(undefined, 9)).toBe("T10");
|
|
});
|
|
|
|
it("never shows T1 when any other team has a standing", () => {
|
|
// Would be wrong to show T1 here — that team isn't first
|
|
expect(getDisplayRank(undefined, 1)).not.toBe("T1");
|
|
expect(getDisplayRank(undefined, 5)).not.toBe("T1");
|
|
});
|
|
});
|
|
});
|