From 85fc2b2176a662424b3efea2cd0c7646c0d8904a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Apr 2026 06:13:21 +0000 Subject: [PATCH] Fix lint: replace non-null assertions with null-safe alternatives in NHL test https://claude.ai/code/session_01139GJVg2gqgDjcUzqhnBNn --- .../simulations/__tests__/nhl-simulator.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/services/simulations/__tests__/nhl-simulator.test.ts b/app/services/simulations/__tests__/nhl-simulator.test.ts index 3088c7c..9e819cf 100644 --- a/app/services/simulations/__tests__/nhl-simulator.test.ts +++ b/app/services/simulations/__tests__/nhl-simulator.test.ts @@ -328,7 +328,8 @@ describe("NHLSimulator — bracket-aware mode", () => { it("throws if an R1 participant slot is missing", async () => { const matches = buildFullNHLBracket(); - const r1m3 = matches.find((m) => m.round === "Wild Card" && m.matchNumber === 3)!; + const r1m3 = matches.find((m) => m.round === "Wild Card" && m.matchNumber === 3); + if (!r1m3) throw new Error("R1 M3 not found in test fixture"); r1m3.participant2Id = null; mockDb.query.playoffMatches.findMany.mockResolvedValue(matches); @@ -387,7 +388,7 @@ describe("NHLSimulator — bracket-aware mode", () => { m.loserId = m.participant2Id; m.isComplete = true; } - const r1Winners = r1.map((m) => m.winnerId!); + const r1Winners = r1.map((m) => m.winnerId ?? ""); // R2: fill from R1 winners, p1 always wins const r2 = matches.filter((m) => m.round === "Divisional"); @@ -398,7 +399,7 @@ describe("NHLSimulator — bracket-aware mode", () => { r2[i].loserId = r2[i].participant2Id; r2[i].isComplete = true; } - const r2Winners = r2.map((m) => m.winnerId!); + const r2Winners = r2.map((m) => m.winnerId ?? ""); // R3: fill from R2 winners, p1 always wins const r3 = matches.filter((m) => m.round === "Conference Finals"); @@ -409,11 +410,12 @@ describe("NHLSimulator — bracket-aware mode", () => { r3[i].loserId = r3[i].participant2Id; r3[i].isComplete = true; } - const r3Winners = r3.map((m) => m.winnerId!); + const r3Winners = r3.map((m) => m.winnerId ?? ""); // Final: t[0] vs t[1], t[0] wins const champion = t[0]; - const final = matches.find((m) => m.round === "Stanley Cup")!; + const final = matches.find((m) => m.round === "Stanley Cup"); + if (!final) throw new Error("Stanley Cup match not found in test fixture"); final.participant1Id = r3Winners[0]; final.participant2Id = r3Winners[1]; final.winnerId = champion;