Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const PredictMarket: React.FC<PredictMarketProps> = ({
entryPoint = PredictEventValues.ENTRY_POINT.PREDICT_FEED,
isCarousel = false,
}) => {
if (market.game?.league === 'nfl') {
if (market.game) {
return (
<PredictMarketSportCard
market={market}
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Predict/constants/sports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PredictSportsLeague } from '../types';
* 3. Add the league to this array
* 4. Add tests for the new league's slug parsing
*/
export const SUPPORTED_SPORTS_LEAGUES: PredictSportsLeague[] = ['nfl'];
export const SUPPORTED_SPORTS_LEAGUES: PredictSportsLeague[] = ['nfl', 'nba'];

export const filterSupportedLeagues = (
leagues: string[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,32 +276,6 @@ describe('TeamsCache', () => {
});
});

describe('getNflTeam', () => {
beforeEach(async () => {
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => mockNflTeams,
});
await TeamsCache.getInstance().ensureLeagueLoaded('nfl');
});

it('returns NFL team by abbreviation', () => {
const cache = TeamsCache.getInstance();

const team = cache.getNflTeam('den');

expect(team?.name).toBe('Denver Broncos');
});

it('returns undefined for unknown NFL team', () => {
const cache = TeamsCache.getInstance();

const team = cache.getNflTeam('unknown');

expect(team).toBeUndefined();
});
});

describe('isLeagueLoaded', () => {
it('returns false for unloaded league', () => {
const cache = TeamsCache.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ export class TeamsCache {
return leagueCache.get(abbreviation.toLowerCase());
}

getNflTeam(abbreviation: string): PolymarketApiTeam | undefined {
return this.getTeam('nfl', abbreviation);
}

isLeagueLoaded(league: PredictSportsLeague): boolean {
return this.cache.has(league);
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Predict/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export type PredictCategory =
| 'politics';

// Sports league types
export type PredictSportsLeague = 'nfl';
export type PredictSportsLeague = 'nfl' | 'nba';

// Game status
export type PredictGameStatus = 'scheduled' | 'ongoing' | 'ended';
Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Predict/utils/gameParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import {
} from '../providers/polymarket/types';

const NFL_SLUG_PATTERN = /^nfl-([a-z]+)-([a-z]+)-(\d{4}-\d{2}-\d{2})$/;
const NBA_SLUG_PATTERN = /^nba-([a-z]+)-([a-z]+)-(\d{4}-\d{2}-\d{2})$/;

const LEAGUE_SLUG_PATTERNS: Record<PredictSportsLeague, RegExp> = {
nfl: NFL_SLUG_PATTERN,
nba: NBA_SLUG_PATTERN,
};

export type TeamLookup = (
Expand Down
Loading