Adds live standings sync and display for bracket-based sports (NBA/NHL), so league members can see W/L tables and which teams their opponents drafted during the regular season — not just after the playoff bracket is set. - New `regular_season_standings` table with upsert-on-conflict sync - Standings sync service with NHL (api-web.nhle.com) and NBA (ESPN) adapters, externalId write-back for future syncs, and unmatched-team resolution UI - `RegularSeasonStandings` component: flat (NBA) + division/wild-card (NHL) modes, playoff line, TeamOwnerBadge, projected Brackt points (EV), mobile horizontal scroll - Admin "Sync Standings" card + "Resolve Unmatched" UI on sports season page - Admin manual standings edit hatch at /admin/sports-seasons/:id/regular-standings - Show standings above bracket until matches exist; below once bracket is set - `normalize-team-name` utility extracted to shared lib Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { normalizeTeamName, findMatchingTeamName } from "../normalize-team-name";
|
|
|
|
describe("normalizeTeamName", () => {
|
|
it("lowercases and trims", () => {
|
|
expect(normalizeTeamName(" Boston Celtics ")).toBe("boston celtics");
|
|
});
|
|
|
|
it("collapses multiple spaces", () => {
|
|
expect(normalizeTeamName("Los Angeles Lakers")).toBe("los angeles lakers");
|
|
});
|
|
|
|
it("is idempotent", () => {
|
|
const name = "oklahoma city thunder";
|
|
expect(normalizeTeamName(name)).toBe(name);
|
|
});
|
|
});
|
|
|
|
describe("findMatchingTeamName", () => {
|
|
const participants = [
|
|
"Boston Celtics",
|
|
"Los Angeles Lakers",
|
|
"Oklahoma City Thunder",
|
|
"Golden State Warriors",
|
|
"Toronto Raptors",
|
|
];
|
|
|
|
it("returns exact case-insensitive match", () => {
|
|
expect(findMatchingTeamName("Boston Celtics", participants)).toBe("Boston Celtics");
|
|
expect(findMatchingTeamName("boston celtics", participants)).toBe("Boston Celtics");
|
|
expect(findMatchingTeamName("TORONTO RAPTORS", participants)).toBe("Toronto Raptors");
|
|
});
|
|
|
|
it("matches partial city+team via substring (e.g. API returns city only)", () => {
|
|
// "Golden State" is a substring of "Golden State Warriors"
|
|
expect(findMatchingTeamName("Golden State", participants)).toBe("Golden State Warriors");
|
|
// "Oklahoma City" is a substring of "Oklahoma City Thunder"
|
|
expect(findMatchingTeamName("Oklahoma City", participants)).toBe("Oklahoma City Thunder");
|
|
});
|
|
|
|
it("returns null for unmatched name", () => {
|
|
expect(findMatchingTeamName("Phoenix Suns", participants)).toBeNull();
|
|
});
|
|
|
|
it("returns null for empty participants list", () => {
|
|
expect(findMatchingTeamName("Boston Celtics", [])).toBeNull();
|
|
});
|
|
});
|