diff --git a/app/models/__tests__/qualifying-bracket-scoring.test.ts b/app/models/__tests__/qualifying-bracket-scoring.test.ts index eb6325f..7e479a1 100644 --- a/app/models/__tests__/qualifying-bracket-scoring.test.ts +++ b/app/models/__tests__/qualifying-bracket-scoring.test.ts @@ -142,7 +142,7 @@ describe("deriveBracketQualifyingStates (simple_8)", () => { it("is idempotent — same matches yield the same states", () => { const a = states([...QF_ALL, ...SF_ALL]); const b = states([...QF_ALL, ...SF_ALL]); - expect([...a.entries()].sort()).toEqual([...b.entries()].sort()); + expect([...a.entries()].toSorted()).toEqual([...b.entries()].toSorted()); }); }); @@ -163,10 +163,10 @@ describe("guaranteed-minimum QP per outcome (default config)", () => { it("end-to-end: a QF win immediately yields a 9 QP floor", () => { const s = states(QF_ALL); - const winner = s.get("t1")!; - expect(qpFor(winner.placement, winner.tieCount)).toBeCloseTo(9); - const loser = s.get("t8")!; - expect(qpFor(loser.placement, loser.tieCount)).toBeCloseTo(4); + expect(s.get("t1")).toEqual({ placement: 3, tieCount: 2 }); + expect(qpFor(3, 2)).toBeCloseTo(9); + expect(s.get("t8")).toEqual({ placement: 5, tieCount: 4 }); + expect(qpFor(5, 4)).toBeCloseTo(4); }); }); @@ -175,12 +175,11 @@ describe("guaranteed-minimum QP per outcome (default config)", () => { describe("structural tie span vs. live-count regrouping", () => { it("4 QF winners share placement 3 but each keeps the 2-slot (9 QP) floor", () => { const s = states(QF_ALL); - const winners = ["t1", "t2", "t3", "t4"].map((id) => s.get(id)!); - // All four sit at placement 3, but with the STRUCTURAL tie span of 2. - for (const w of winners) { - expect(w).toEqual({ placement: 3, tieCount: 2 }); - expect(qpFor(w.placement, w.tieCount)).toBeCloseTo(9); + // All four QF winners sit at placement 3, but with the STRUCTURAL tie span of 2. + for (const id of ["t1", "t2", "t3", "t4"]) { + expect(s.get(id)).toEqual({ placement: 3, tieCount: 2 }); } + expect(qpFor(3, 2)).toBeCloseTo(9); // A naive regroup by LIVE count (4 rows at placement 3) would average over // slots 3–6 and wrongly yield 7 QP — the bug processQualifyingEvent must avoid // by delegating bracket events to the structural-tieCount path.