tests cleanup

This commit is contained in:
2026-01-03 16:51:40 +01:00
parent e151fe02d0
commit 540c0fcb7a
34 changed files with 395 additions and 4402 deletions

View File

@@ -4,8 +4,63 @@ import { EventScoringService } from '@core/racing/domain/services/EventScoringSe
import type { BonusRule } from '@core/racing/domain/types/BonusRule';
import { Result } from '@core/racing/domain/entities/result/Result';
import type { Penalty } from '@core/racing/domain/entities/Penalty';
import { makeChampionshipConfig } from '../../../testing/factories/racing/ChampionshipConfigFactory';
import type { ChampionshipConfig } from '@core/racing/domain/types/ChampionshipConfig';
import type { SessionType } from '@core/racing/domain/types/SessionType';
import { PointsTable } from '@core/racing/domain/value-objects/PointsTable';
const makeChampionshipConfig = (params: {
id: string;
name: string;
sessionTypes: SessionType[];
mainPoints: number[];
sprintPoints?: number[];
mainBonusRules?: BonusRule[];
}): ChampionshipConfig => {
const { id, name, sessionTypes, mainPoints, sprintPoints, mainBonusRules } = params;
const pointsTableBySessionType: Record<SessionType, PointsTable> = {} as Record<SessionType, PointsTable>;
sessionTypes.forEach((sessionType) => {
if (sessionType === 'main') {
pointsTableBySessionType[sessionType] = new PointsTable(
mainPoints.reduce((acc, points, index) => {
acc[index + 1] = points;
return acc;
}, {} as Record<number, number>),
);
} else if (sessionType === 'sprint' && sprintPoints) {
pointsTableBySessionType[sessionType] = new PointsTable(
sprintPoints.reduce((acc, points, index) => {
acc[index + 1] = points;
return acc;
}, {} as Record<number, number>),
);
} else {
pointsTableBySessionType[sessionType] = new PointsTable({});
}
});
const bonusRulesBySessionType: Record<SessionType, BonusRule[]> = {} as Record<SessionType, BonusRule[]>;
sessionTypes.forEach((sessionType) => {
if (sessionType === 'main' && mainBonusRules) {
bonusRulesBySessionType[sessionType] = mainBonusRules;
} else {
bonusRulesBySessionType[sessionType] = [];
}
});
return {
id,
name,
type: 'driver',
sessionTypes,
pointsTableBySessionType,
bonusRulesBySessionType,
dropScorePolicy: {
strategy: 'none',
},
};
};
describe('EventScoringService', () => {
const seasonId = 'season-1';
@@ -201,4 +256,4 @@ describe('EventScoringService', () => {
(mapWithBonus.get('driver-3')?.penaltyPoints || 0),
);
});
});
});