add website tests
This commit is contained in:
@@ -24,6 +24,20 @@ import type { UpdateLeagueMemberRoleOutputDTO } from '../../types/generated/Upda
|
||||
import type { RemoveLeagueMemberOutputDTO } from '../../types/generated/RemoveLeagueMemberOutputDTO';
|
||||
import type { AllLeaguesWithCapacityAndScoringDTO } from '../../types/AllLeaguesWithCapacityAndScoringDTO';
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null;
|
||||
}
|
||||
|
||||
function isRaceDTO(value: unknown): value is RaceDTO {
|
||||
if (!isRecord(value)) return false;
|
||||
return typeof value.id === 'string' && typeof value.name === 'string' && typeof value.date === 'string';
|
||||
}
|
||||
|
||||
function parseRaceDTOArray(value: unknown): RaceDTO[] {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value.filter(isRaceDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leagues API Client
|
||||
*
|
||||
@@ -145,8 +159,9 @@ export class LeaguesApiClient extends BaseApiClient {
|
||||
}
|
||||
|
||||
/** Get races for a league */
|
||||
getRaces(leagueId: string): Promise<{ races: RaceDTO[] }> {
|
||||
return this.get<{ races: RaceDTO[] }>(`/leagues/${leagueId}/races`);
|
||||
async getRaces(leagueId: string): Promise<{ races: RaceDTO[] }> {
|
||||
const response = await this.get<{ races?: unknown }>(`/leagues/${leagueId}/races`);
|
||||
return { races: parseRaceDTOArray(response?.races) };
|
||||
}
|
||||
|
||||
/** Admin roster: list current members (admin/owner only; actor derived from session) */
|
||||
|
||||
Reference in New Issue
Block a user