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
59 lines
1.8 KiB
TypeScript
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();
|
|
});
|
|
});
|