brackt/app/components/__tests__/QualifyingPointsStandings.test.tsx
Claude cab161424e
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 3m6s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m21s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
Trim trailing zeros on qualifying-points values
Display fractional QP with up to 2 decimals and trailing zeros trimmed
(1.50→1.5, 0.50→0.5) in both the Discord embed (formatQPValue) and the web
UI (formatQP) so the two surfaces stay consistent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011U7mTxDVK2cH8E2BWjCiUv
2026-07-09 06:34:25 +00:00

59 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { QualifyingPointsStandings } from "~/components/scoring/QualifyingPointsStandings";
const scoringRules = {
pointsFor1st: 100,
pointsFor2nd: 70,
pointsFor3rd: 50,
pointsFor4th: 40,
pointsFor5th: 25,
pointsFor6th: 25,
pointsFor7th: 15,
pointsFor8th: 15,
};
describe("QualifyingPointsStandings", () => {
it("renders fractional QP to at most hundredths with trailing zeros trimmed", () => {
render(
<QualifyingPointsStandings
standings={[
{
id: "standing-1",
totalQualifyingPoints: "14.67",
eventsScored: 1,
finalRanking: null,
globalRank: 1,
participant: { id: "participant-1", name: "Player One" },
},
{
id: "standing-2",
totalQualifyingPoints: "0.50",
eventsScored: 1,
finalRanking: null,
globalRank: 2,
participant: { id: "participant-2", name: "Player Two" },
},
{
id: "standing-3",
totalQualifyingPoints: "0.43",
eventsScored: 1,
finalRanking: null,
globalRank: 3,
participant: { id: "participant-3", name: "Player Three" },
},
]}
scoringRules={scoringRules}
isFinalized={false}
totalMajors={4}
majorsCompleted={1}
canFinalize={false}
/>
);
expect(screen.getByText("14.67 QP")).toBeInTheDocument();
// 0.50 trims its trailing zero to 0.5; 14.67 and 0.43 are unaffected.
expect(screen.getByText("0.5 QP")).toBeInTheDocument();
expect(screen.getByText("0.43 QP")).toBeInTheDocument();
});
});