website refactor
This commit is contained in:
@@ -5,14 +5,12 @@ import { TeamRatingRepository } from '@core/racing/domain/repositories/TeamRatin
|
||||
import { TeamDrivingRaceFactsDto } from '@core/racing/domain/services/TeamDrivingRatingEventFactory';
|
||||
import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent';
|
||||
import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId';
|
||||
import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey';
|
||||
import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta';
|
||||
|
||||
// Mock repositories
|
||||
class MockTeamRaceResultsProvider implements TeamRaceResultsProvider {
|
||||
private results: TeamDrivingRaceFactsDto | null = null;
|
||||
|
||||
async getTeamRaceResults(raceId: string): Promise<TeamDrivingRaceFactsDto | null> {
|
||||
async getTeamRaceResults(): Promise<TeamDrivingRaceFactsDto | null> {
|
||||
return this.results;
|
||||
}
|
||||
|
||||
@@ -41,7 +39,7 @@ class MockTeamRatingEventRepository implements TeamRatingEventRepository {
|
||||
return this.events.filter(e => e.teamId === teamId);
|
||||
}
|
||||
|
||||
async findEventsPaginated(teamId: string): Promise<any> {
|
||||
async findEventsPaginated(teamId: string): Promise<PaginatedResult<TeamRatingEvent>> {
|
||||
const events = await this.getAllByTeamId(teamId);
|
||||
return {
|
||||
items: events,
|
||||
@@ -58,13 +56,13 @@ class MockTeamRatingEventRepository implements TeamRatingEventRepository {
|
||||
}
|
||||
|
||||
class MockTeamRatingRepository implements TeamRatingRepository {
|
||||
private snapshots: Map<string, any> = new Map();
|
||||
private snapshots: Map<string, TeamRating> = new Map();
|
||||
|
||||
async findByTeamId(teamId: string): Promise<any | null> {
|
||||
async findByTeamId(teamId: string): Promise<TeamRating | null> {
|
||||
return this.snapshots.get(teamId) || null;
|
||||
}
|
||||
|
||||
async save(snapshot: any): Promise<any> {
|
||||
async save(snapshot: TeamRating): Promise<TeamRating> {
|
||||
this.snapshots.set(snapshot.teamId, snapshot);
|
||||
return snapshot;
|
||||
}
|
||||
@@ -202,7 +200,6 @@ describe('TeamRatingIntegrationAdapter', () => {
|
||||
mockResultsProvider.setResults(raceResults);
|
||||
|
||||
// Mock repository to throw error
|
||||
const originalSave = mockEventRepo.save.bind(mockEventRepo);
|
||||
mockEventRepo.save = async () => {
|
||||
throw new Error('Repository error');
|
||||
};
|
||||
@@ -276,12 +273,11 @@ describe('TeamRatingIntegrationAdapter', () => {
|
||||
mockResultsProvider.setResults(raceResults);
|
||||
|
||||
// Mock repository to fail for team-456
|
||||
const originalSave = mockEventRepo.save.bind(mockEventRepo);
|
||||
mockEventRepo.save = async (event) => {
|
||||
if (event.teamId === 'team-456') {
|
||||
throw new Error('Simulated failure');
|
||||
}
|
||||
return originalSave(event);
|
||||
return event;
|
||||
};
|
||||
|
||||
const result = await adapter.recordTeamRatingsWithDetails('race-123');
|
||||
|
||||
Reference in New Issue
Block a user