refactor
This commit is contained in:
@@ -7,6 +7,12 @@ import type { IRaceRepository } from '../../domain/repositories/IRaceRepository'
|
||||
import type { DriverRatingPort } from '../ports/DriverRatingPort';
|
||||
|
||||
describe('GetLeagueDriverSeasonStatsUseCase', () => {
|
||||
const mockStandingFindByLeagueId = vi.fn();
|
||||
const mockResultFindByDriverIdAndLeagueId = vi.fn();
|
||||
const mockPenaltyFindByRaceId = vi.fn();
|
||||
const mockRaceFindByLeagueId = vi.fn();
|
||||
const mockDriverRatingGetRating = vi.fn();
|
||||
|
||||
let useCase: GetLeagueDriverSeasonStatsUseCase;
|
||||
let standingRepository: IStandingRepository;
|
||||
let resultRepository: IResultRepository;
|
||||
@@ -16,20 +22,38 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
standingRepository = {
|
||||
findByLeagueId: vi.fn(),
|
||||
} as any;
|
||||
resultRepository = {
|
||||
findByLeagueId: mockStandingFindByLeagueId,
|
||||
findByDriverIdAndLeagueId: vi.fn(),
|
||||
} as any;
|
||||
findAll: vi.fn(),
|
||||
save: vi.fn(),
|
||||
saveMany: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
deleteByLeagueId: vi.fn(),
|
||||
exists: vi.fn(),
|
||||
recalculate: vi.fn(),
|
||||
};
|
||||
resultRepository = {
|
||||
findByDriverIdAndLeagueId: mockResultFindByDriverIdAndLeagueId,
|
||||
};
|
||||
penaltyRepository = {
|
||||
findByRaceId: vi.fn(),
|
||||
} as any;
|
||||
findByRaceId: mockPenaltyFindByRaceId,
|
||||
};
|
||||
raceRepository = {
|
||||
findByLeagueId: vi.fn(),
|
||||
} as any;
|
||||
findById: vi.fn(),
|
||||
findAll: vi.fn(),
|
||||
findByLeagueId: mockRaceFindByLeagueId,
|
||||
findUpcomingByLeagueId: vi.fn(),
|
||||
findCompletedByLeagueId: vi.fn(),
|
||||
findByStatus: vi.fn(),
|
||||
findByDateRange: vi.fn(),
|
||||
create: vi.fn(),
|
||||
update: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
exists: vi.fn(),
|
||||
};
|
||||
driverRatingPort = {
|
||||
getRating: vi.fn(),
|
||||
} as any;
|
||||
getRating: mockDriverRatingGetRating,
|
||||
};
|
||||
|
||||
useCase = new GetLeagueDriverSeasonStatsUseCase(
|
||||
standingRepository,
|
||||
@@ -69,7 +93,7 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
|
||||
const result = await useCase.execute(params);
|
||||
|
||||
expect(result.isOk()).toBe(true);
|
||||
const dto = result.unwrap();
|
||||
const dto = result.value!;
|
||||
expect(dto.leagueId).toBe('league-1');
|
||||
expect(dto.standings).toEqual([
|
||||
{ driverId: 'driver-1', position: 1, points: 100, racesCompleted: 5 },
|
||||
@@ -97,7 +121,7 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => {
|
||||
const result = await useCase.execute(params);
|
||||
|
||||
expect(result.isOk()).toBe(true);
|
||||
const dto = result.unwrap();
|
||||
const dto = result.value!;
|
||||
expect(dto.penalties.size).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user