This commit is contained in:
2025-12-12 23:49:56 +01:00
parent cae81b1088
commit 8f1db21fb1
29 changed files with 879 additions and 399 deletions

View File

@@ -6,9 +6,9 @@ import type { SessionType } from '@gridpilot/racing/domain/types/SessionType';
import { PointsTable } from '@gridpilot/racing/domain/value-objects/PointsTable';
import type { BonusRule } from '@gridpilot/racing/domain/types/BonusRule';
import type { ChampionshipConfig } from '@gridpilot/racing/domain/types/ChampionshipConfig';
import type { Result } from '@gridpilot/racing/domain/entities/Result';
import { Result } from '@gridpilot/racing/domain/entities/Result';
import type { Penalty } from '@gridpilot/racing/domain/entities/Penalty';
import type { ChampionshipType } from '@gridpilot/racing/domain/value-objects/ChampionshipType';
import type { ChampionshipType } from '@gridpilot/racing/domain/types/ChampionshipType';
function makeDriverRef(id: string): ParticipantRef {
return {
@@ -83,7 +83,7 @@ describe('EventScoringService', () => {
});
const results: Result[] = [
{
Result.create({
id: 'result-1',
raceId: 'race-1',
driverId: 'driver-1',
@@ -91,8 +91,8 @@ describe('EventScoringService', () => {
fastestLap: 90000,
incidents: 0,
startPosition: 1,
},
{
}),
Result.create({
id: 'result-2',
raceId: 'race-1',
driverId: 'driver-2',
@@ -100,8 +100,8 @@ describe('EventScoringService', () => {
fastestLap: 90500,
incidents: 0,
startPosition: 2,
},
{
}),
Result.create({
id: 'result-3',
raceId: 'race-1',
driverId: 'driver-3',
@@ -109,8 +109,8 @@ describe('EventScoringService', () => {
fastestLap: 91000,
incidents: 0,
startPosition: 3,
},
{
}),
Result.create({
id: 'result-4',
raceId: 'race-1',
driverId: 'driver-4',
@@ -118,8 +118,8 @@ describe('EventScoringService', () => {
fastestLap: 91500,
incidents: 0,
startPosition: 4,
},
{
}),
Result.create({
id: 'result-5',
raceId: 'race-1',
driverId: 'driver-5',
@@ -127,7 +127,7 @@ describe('EventScoringService', () => {
fastestLap: 92000,
incidents: 0,
startPosition: 5,
},
}),
];
const penalties: Penalty[] = [];
@@ -179,30 +179,30 @@ describe('EventScoringService', () => {
} as const;
const resultsP11Fastest: Result[] = [
{
Result.create({
id: 'result-1',
...baseResultTemplate,
driverId: 'driver-1',
position: 1,
startPosition: 1,
fastestLap: 91000,
},
{
}),
Result.create({
id: 'result-2',
...baseResultTemplate,
driverId: 'driver-2',
position: 2,
startPosition: 2,
fastestLap: 90500,
},
{
}),
Result.create({
id: 'result-3',
...baseResultTemplate,
driverId: 'driver-3',
position: 11,
startPosition: 15,
fastestLap: 90000,
},
}),
];
const penalties: Penalty[] = [];
@@ -220,30 +220,30 @@ describe('EventScoringService', () => {
expect(mapNoBonus.get('driver-3')?.bonusPoints).toBe(0);
const resultsP8Fastest: Result[] = [
{
Result.create({
id: 'result-1',
...baseResultTemplate,
driverId: 'driver-1',
position: 1,
startPosition: 1,
fastestLap: 91000,
},
{
}),
Result.create({
id: 'result-2',
...baseResultTemplate,
driverId: 'driver-2',
position: 2,
startPosition: 2,
fastestLap: 90500,
},
{
}),
Result.create({
id: 'result-3',
...baseResultTemplate,
driverId: 'driver-3',
position: 8,
startPosition: 15,
fastestLap: 90000,
},
}),
];
const pointsWithBonus = service.scoreSession({