website refactor

This commit is contained in:
2026-01-21 16:52:43 +01:00
parent ac37871bef
commit 2325eef8b5
18 changed files with 835 additions and 47 deletions

View File

@@ -146,6 +146,41 @@ describe('GetLeagueScheduleUseCase', () => {
expect(resultValue.races).toHaveLength(0);
});
it('should present all races when no seasons exist for league', async () => {
const leagueId = 'league-1';
const league = { id: leagueId } as unknown as League;
const race1 = Race.create({
id: 'race-1',
leagueId,
scheduledAt: new Date('2025-01-10T20:00:00Z'),
track: 'Track 1',
car: 'Car 1',
});
const race2 = Race.create({
id: 'race-2',
leagueId,
scheduledAt: new Date('2025-01-15T20:00:00Z'),
track: 'Track 2',
car: 'Car 2',
});
leagueRepository.findById.mockResolvedValue(league);
seasonRepository.findByLeagueId.mockResolvedValue([]);
raceRepository.findByLeagueId.mockResolvedValue([race1, race2]);
const input: GetLeagueScheduleInput = { leagueId };
const result = await useCase.execute(input);
expect(result.isOk()).toBe(true);
const resultValue = result.unwrap();
expect(resultValue.league).toBe(league);
expect(resultValue.seasonId).toBe('no-season');
expect(resultValue.published).toBe(false);
expect(resultValue.races).toHaveLength(2);
expect(resultValue.races[0]?.race).toBe(race1);
expect(resultValue.races[1]?.race).toBe(race2);
});
it('should return LEAGUE_NOT_FOUND error when league does not exist', async () => {
const leagueId = 'missing-league';