2026-05-17 21:58:53 -07:00
|
|
|
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", () => {
|
2026-07-09 06:34:25 +00:00
|
|
|
it("renders fractional QP to at most hundredths with trailing zeros trimmed", () => {
|
2026-05-17 21:58:53 -07:00
|
|
|
render(
|
|
|
|
|
<QualifyingPointsStandings
|
|
|
|
|
standings={[
|
|
|
|
|
{
|
|
|
|
|
id: "standing-1",
|
|
|
|
|
totalQualifyingPoints: "14.67",
|
|
|
|
|
eventsScored: 1,
|
|
|
|
|
finalRanking: null,
|
2026-06-06 09:38:47 -07:00
|
|
|
globalRank: 1,
|
2026-05-17 21:58:53 -07:00
|
|
|
participant: { id: "participant-1", name: "Player One" },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "standing-2",
|
|
|
|
|
totalQualifyingPoints: "0.50",
|
|
|
|
|
eventsScored: 1,
|
|
|
|
|
finalRanking: null,
|
2026-06-06 09:38:47 -07:00
|
|
|
globalRank: 2,
|
2026-05-17 21:58:53 -07:00
|
|
|
participant: { id: "participant-2", name: "Player Two" },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "standing-3",
|
|
|
|
|
totalQualifyingPoints: "0.43",
|
|
|
|
|
eventsScored: 1,
|
|
|
|
|
finalRanking: null,
|
2026-06-06 09:38:47 -07:00
|
|
|
globalRank: 3,
|
2026-05-17 21:58:53 -07:00
|
|
|
participant: { id: "participant-3", name: "Player Three" },
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
scoringRules={scoringRules}
|
|
|
|
|
isFinalized={false}
|
|
|
|
|
totalMajors={4}
|
|
|
|
|
majorsCompleted={1}
|
|
|
|
|
canFinalize={false}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByText("14.67 QP")).toBeInTheDocument();
|
2026-07-09 06:34:25 +00:00
|
|
|
// 0.50 trims its trailing zero to 0.5; 14.67 and 0.43 are unaffected.
|
|
|
|
|
expect(screen.getByText("0.5 QP")).toBeInTheDocument();
|
2026-05-17 21:58:53 -07:00
|
|
|
expect(screen.getByText("0.43 QP")).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|