fix issues in core

This commit is contained in:
2025-12-23 14:43:49 +01:00
parent 11492d1ff2
commit df5c20c5cc
62 changed files with 480 additions and 334 deletions

View File

@@ -55,10 +55,29 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
recalculate: vi.fn(),
};
resultRepository = {
findById: vi.fn(),
findAll: vi.fn(),
findByRaceId: vi.fn(),
findByDriverId: vi.fn(),
findByDriverIdAndLeagueId: mockResultFindByDriverIdAndLeagueId,
create: vi.fn(),
createMany: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
deleteByRaceId: vi.fn(),
exists: vi.fn(),
existsByRaceId: vi.fn(),
};
penaltyRepository = {
findById: vi.fn(),
findByDriverId: vi.fn(),
findByProtestId: vi.fn(),
findPending: vi.fn(),
findByRaceId: mockPenaltyFindByRaceId,
findIssuedBy: vi.fn(),
create: vi.fn(),
update: vi.fn(),
exists: vi.fn(),
};
raceRepository = {
findById: vi.fn(),
@@ -75,12 +94,27 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
};
driverRepository = {
findById: mockDriverFindById,
findByIRacingId: vi.fn(),
findAll: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
exists: vi.fn(),
existsByIRacingId: vi.fn(),
};
teamRepository = {
findById: mockTeamFindById,
findAll: vi.fn(),
findByLeagueId: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
exists: vi.fn(),
};
driverRatingPort = {
getRating: mockDriverRatingGetRating,
getDriverRating: mockDriverRatingGetRating,
calculateRatingChange: vi.fn(),
updateDriverRating: vi.fn(),
};
output = {
@@ -138,7 +172,7 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
expect(result.unwrap()).toBeUndefined();
expect(output.present).toHaveBeenCalledTimes(1);
const presented = output.present.mock.calls[0][0] as GetLeagueDriverSeasonStatsResult;
const presented = output.present.mock.calls[0]?.[0] as GetLeagueDriverSeasonStatsResult;
expect(presented.leagueId).toBe('league-1');
expect(presented.stats).toHaveLength(2);
expect(presented.stats[0]).toEqual({
@@ -188,8 +222,8 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
expect(result.unwrap()).toBeUndefined();
expect(output.present).toHaveBeenCalledTimes(1);
const presented = output.present.mock.calls[0][0] as GetLeagueDriverSeasonStatsResult;
expect(presented.stats[0].penaltyPoints).toBe(0);
const presented = output.present.mock.calls[0]?.[0] as GetLeagueDriverSeasonStatsResult;
expect(presented?.stats[0]?.penaltyPoints).toBe(0);
});
it('should return LEAGUE_NOT_FOUND when no standings are found', async () => {