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.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { findMatchingTeamName } from "~/lib/normalize-team-name";
|
|
|
|
// Pure unit tests for the name-matching logic used by syncStandings.
|
|
// The full orchestrator requires DB context; those are covered by integration tests.
|
|
|
|
describe("findMatchingTeamName (sync name-matching logic)", () => {
|
|
const participants = [
|
|
"Boston Celtics",
|
|
"Los Angeles Lakers",
|
|
"Golden State Warriors",
|
|
"Oklahoma City Thunder",
|
|
"San Antonio Spurs",
|
|
"New York Knicks",
|
|
];
|
|
|
|
it("matches exact names", () => {
|
|
expect(findMatchingTeamName("Boston Celtics", participants)).toBe("Boston Celtics");
|
|
expect(findMatchingTeamName("New York Knicks", participants)).toBe("New York Knicks");
|
|
});
|
|
|
|
it("is case-insensitive", () => {
|
|
expect(findMatchingTeamName("golden state warriors", participants)).toBe(
|
|
"Golden State Warriors"
|
|
);
|
|
expect(findMatchingTeamName("SAN ANTONIO SPURS", participants)).toBe("San Antonio Spurs");
|
|
});
|
|
|
|
it("matches partial city+team via substring", () => {
|
|
expect(findMatchingTeamName("Golden State", participants)).toBe("Golden State Warriors");
|
|
expect(findMatchingTeamName("Oklahoma City", participants)).toBe("Oklahoma City Thunder");
|
|
// "New York" is a substring of "New York Knicks"
|
|
expect(findMatchingTeamName("New York", participants)).toBe("New York Knicks");
|
|
});
|
|
|
|
it("returns null for truly unmatched names", () => {
|
|
expect(findMatchingTeamName("Phoenix Suns", participants)).toBeNull();
|
|
expect(findMatchingTeamName("Charlotte Hornets", participants)).toBeNull();
|
|
});
|
|
|
|
it("returns null for empty string", () => {
|
|
expect(findMatchingTeamName("", participants)).toBeNull();
|
|
});
|
|
|
|
it("handles extra whitespace gracefully", () => {
|
|
expect(findMatchingTeamName(" Boston Celtics ", participants)).toBe("Boston Celtics");
|
|
});
|
|
});
|