website refactor

This commit is contained in:
2026-01-16 18:21:06 +01:00
parent 2f53727702
commit 095885544b
146 changed files with 970 additions and 524 deletions

View File

@@ -1,9 +1,8 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import {
GetLeagueDriverSeasonStatsUseCase,
type GetLeagueDriverSeasonStatsErrorCode,
type GetLeagueDriverSeasonStatsInput,
type GetLeagueDriverSeasonStatsResult,
} from './GetLeagueDriverSeasonStatsUseCase';
import type { StandingRepository } from '../../domain/repositories/StandingRepository';
import type { ResultRepository } from '../../domain/repositories/ResultRepository';
@@ -22,12 +21,70 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
const mockDriverFindById = vi.fn();
let useCase: GetLeagueDriverSeasonStatsUseCase;
let standingRepository: any;
let resultRepository: any;
let penaltyRepository: any;
let raceRepository: any;
let driverRepository: any;
let driverRatingPort: any;
let standingRepository: {
findByLeagueId: Mock;
findByDriverIdAndLeagueId: Mock;
findAll: Mock;
save: Mock;
saveMany: Mock;
delete: Mock;
deleteByLeagueId: Mock;
exists: Mock;
recalculate: Mock;
};
let resultRepository: {
findById: Mock;
findAll: Mock;
findByRaceId: Mock;
findByDriverId: Mock;
findByDriverIdAndLeagueId: Mock;
create: Mock;
createMany: Mock;
update: Mock;
delete: Mock;
deleteByRaceId: Mock;
exists: Mock;
existsByRaceId: Mock;
};
let penaltyRepository: {
findById: Mock;
findByDriverId: Mock;
findByProtestId: Mock;
findPending: Mock;
findByRaceId: Mock;
findIssuedBy: Mock;
create: Mock;
update: Mock;
exists: Mock;
};
let raceRepository: {
findById: Mock;
findAll: Mock;
findByLeagueId: Mock;
findUpcomingByLeagueId: Mock;
findCompletedByLeagueId: Mock;
findByStatus: Mock;
findByDateRange: Mock;
create: Mock;
update: Mock;
delete: Mock;
exists: Mock;
};
let driverRepository: {
findById: Mock;
findByIRacingId: Mock;
findAll: Mock;
create: Mock;
update: Mock;
delete: Mock;
exists: Mock;
existsByIRacingId: Mock;
};
let driverRatingPort: {
getDriverRating: Mock;
calculateRatingChange: Mock;
updateDriverRating: Mock;
};
beforeEach(() => {
mockStandingFindByLeagueId.mockReset();
@@ -102,12 +159,14 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
updateDriverRating: vi.fn(),
};
useCase = new GetLeagueDriverSeasonStatsUseCase(standingRepository,
resultRepository,
penaltyRepository,
raceRepository,
driverRepository,
driverRatingPort);
useCase = new GetLeagueDriverSeasonStatsUseCase(
standingRepository as unknown as StandingRepository,
resultRepository as unknown as ResultRepository,
penaltyRepository as unknown as PenaltyRepository,
raceRepository as unknown as RaceRepository,
driverRepository as unknown as DriverRepository,
driverRatingPort as unknown as DriverRatingPort
);
});
it('should return league driver season stats for given league id', async () => {