brackt/app/services/standings-sync/__tests__/sync.test.ts
Chris Parsons bf0ddaa8aa 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>
2026-03-21 09:40:15 -07:00

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");
});
});