brackt/app/lib/__tests__/standings-display.test.ts

41 lines
1.5 KiB
TypeScript
Raw Normal View History

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");
});
});
});