* Add projected-wins input mode to admin Elo Ratings page Admins can now enter projected season win totals instead of raw Elo numbers on the Elo Ratings page. Wins are auto-converted to Elo using the inverse formula and stored as sourceElo, keeping the rest of the simulation pipeline unchanged. - Add `projectedWinsToElo` / `eloToProjectedWins` to probability-engine - Add `simulator-config.ts` centralising per-sport season length, parity factor, and average opponent Elo (AFL, NFL, NBA, NHL, MLB, WNBA) - Admin Elo Ratings page: toggle between Elo and Projected Wins input modes; bulk import parses wins format; existing sourceElo back-fills the wins field on load - AFL simulator now reads sourceElo from participantExpectedValues first, falling back to hardcoded TEAMS_DATA then 1400 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix lint errors in simulator-config tests and probability-engine - Replace non-null assertions (`!`) with optional chaining (`?.`) in simulator-config tests - Remove redundant type annotations on default parameters in probability-engine Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { getSimulatorConfig, supportsProjectedWins } from "../simulator-config";
|
|
|
|
describe("simulator-config", () => {
|
|
describe("getSimulatorConfig", () => {
|
|
it("returns config for afl_bracket", () => {
|
|
const config = getSimulatorConfig("afl_bracket");
|
|
expect(config).not.toBeNull();
|
|
expect(config?.seasonGames).toBe(23);
|
|
expect(config?.parityFactor).toBe(450);
|
|
expect(config?.averageOpponentElo).toBe(1500);
|
|
});
|
|
|
|
it("returns config for nfl_bracket", () => {
|
|
const config = getSimulatorConfig("nfl_bracket");
|
|
expect(config).not.toBeNull();
|
|
expect(config?.seasonGames).toBe(17);
|
|
expect(config?.parityFactor).toBe(400);
|
|
});
|
|
|
|
it("returns config for nba_bracket", () => {
|
|
const config = getSimulatorConfig("nba_bracket");
|
|
expect(config).not.toBeNull();
|
|
expect(config?.seasonGames).toBe(82);
|
|
});
|
|
|
|
it("returns config for nhl_bracket", () => {
|
|
const config = getSimulatorConfig("nhl_bracket");
|
|
expect(config).not.toBeNull();
|
|
expect(config?.seasonGames).toBe(82);
|
|
expect(config?.parityFactor).toBe(1000);
|
|
});
|
|
|
|
it("returns config for mlb_bracket", () => {
|
|
const config = getSimulatorConfig("mlb_bracket");
|
|
expect(config).not.toBeNull();
|
|
expect(config?.seasonGames).toBe(162);
|
|
});
|
|
|
|
it("returns null for snooker_bracket", () => {
|
|
expect(getSimulatorConfig("snooker_bracket")).toBeNull();
|
|
});
|
|
|
|
it("returns null for darts_bracket", () => {
|
|
expect(getSimulatorConfig("darts_bracket")).toBeNull();
|
|
});
|
|
|
|
it("returns null for playoff_bracket", () => {
|
|
expect(getSimulatorConfig("playoff_bracket")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("supportsProjectedWins", () => {
|
|
it("returns true for afl_bracket", () => {
|
|
expect(supportsProjectedWins("afl_bracket")).toBe(true);
|
|
});
|
|
|
|
it("returns true for nfl_bracket", () => {
|
|
expect(supportsProjectedWins("nfl_bracket")).toBe(true);
|
|
});
|
|
|
|
it("returns false for snooker_bracket", () => {
|
|
expect(supportsProjectedWins("snooker_bracket")).toBe(false);
|
|
});
|
|
|
|
it("returns false for darts_bracket", () => {
|
|
expect(supportsProjectedWins("darts_bracket")).toBe(false);
|
|
});
|
|
});
|
|
});
|