* Add oxlint and fix all lint errors - Install oxlint, add .oxlintrc.json with rules for TypeScript/React - Add npm run lint / lint:fix scripts - Add Claude PostToolUse hook to run oxlint on every edited file - Fix 101 errors: unused vars/imports, eqeqeq, prefer-const, no-new-array - Fix no-array-index-key (use stable keys or suppress positional cases) - Fix exhaustive-deps missing dependency in useEffect - Promote exhaustive-deps and no-array-index-key to errors - Fix Map.get() !== null bug in $leagueId.server.ts (should be !== undefined) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix no-explicit-any warnings and upgrade tsconfig to ES2023 - Replace all `any` types with proper types or `unknown` across ~20 files - Add typed socket payload interfaces in draft route and useDraftSocket - Use any[] with eslint-disable for socket.io callbacks (legitimate escape hatch) - Bump all tsconfigs from ES2022 → ES2023 to support toSorted/toReversed - Fix cascading type errors uncovered by removing any: Map.get narrowing, participant relation types, ChartDataPoint, Partial<NewSeason> indexing - Add ParticipantResultWithParticipant type to participant-result model - Fix test fixtures to match updated interfaces (DraftCell, ParticipantResult) - Fix duplicate getQPStandings import in sportsSeasonId.server.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Promote no-explicit-any to error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { describe, it, expect } 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");
|
|
});
|
|
});
|