wip
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -75,9 +75,9 @@ describe('ScheduleCalculator', () => {
|
||||
expect(date.getDay()).toBe(6); // Saturday
|
||||
});
|
||||
// First race should be Jan 6
|
||||
expect(result.raceDates[0].toISOString().split('T')[0]).toBe('2024-01-06');
|
||||
expect(result.raceDates[0]!.toISOString().split('T')[0]).toBe('2024-01-06');
|
||||
// Last race should be 7 weeks later (Feb 24)
|
||||
expect(result.raceDates[7].toISOString().split('T')[0]).toBe('2024-02-24');
|
||||
expect(result.raceDates[7]!.toISOString().split('T')[0]).toBe('2024-02-24');
|
||||
});
|
||||
|
||||
it('should schedule races on multiple weekdays', () => {
|
||||
@@ -138,13 +138,13 @@ describe('ScheduleCalculator', () => {
|
||||
// Then
|
||||
expect(result.raceDates.length).toBe(4);
|
||||
// First race Jan 6
|
||||
expect(result.raceDates[0].toISOString().split('T')[0]).toBe('2024-01-06');
|
||||
expect(result.raceDates[0]!.toISOString().split('T')[0]).toBe('2024-01-06');
|
||||
// Second race 2 weeks later (Jan 20)
|
||||
expect(result.raceDates[1].toISOString().split('T')[0]).toBe('2024-01-20');
|
||||
expect(result.raceDates[1]!.toISOString().split('T')[0]).toBe('2024-01-20');
|
||||
// Third race 2 weeks later (Feb 3)
|
||||
expect(result.raceDates[2].toISOString().split('T')[0]).toBe('2024-02-03');
|
||||
expect(result.raceDates[2]!.toISOString().split('T')[0]).toBe('2024-02-03');
|
||||
// Fourth race 2 weeks later (Feb 17)
|
||||
expect(result.raceDates[3].toISOString().split('T')[0]).toBe('2024-02-17');
|
||||
expect(result.raceDates[3]!.toISOString().split('T')[0]).toBe('2024-02-17');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -165,7 +165,7 @@ describe('ScheduleCalculator', () => {
|
||||
// Then
|
||||
expect(result.raceDates.length).toBe(8);
|
||||
// First race should be at or near start
|
||||
expect(result.raceDates[0].toISOString().split('T')[0]).toBe('2024-01-06');
|
||||
expect(result.raceDates[0]!.toISOString().split('T')[0]).toBe('2024-01-06');
|
||||
// Races should be spread across the range, not consecutive weeks
|
||||
});
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('CheckoutConfirmation Value Object', () => {
|
||||
});
|
||||
|
||||
it('should throw error for invalid decision', () => {
|
||||
expect(() => CheckoutConfirmation.create('invalid')).toThrow(
|
||||
expect(() => CheckoutConfirmation.create('invalid' as any)).toThrow(
|
||||
'Invalid checkout confirmation decision',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -44,11 +44,11 @@ describe('SessionState Value Object', () => {
|
||||
});
|
||||
|
||||
it('should throw error for invalid state', () => {
|
||||
expect(() => SessionState.create('INVALID')).toThrow('Invalid session state');
|
||||
expect(() => SessionState.create('INVALID' as any)).toThrow('Invalid session state');
|
||||
});
|
||||
|
||||
|
||||
it('should throw error for empty string', () => {
|
||||
expect(() => SessionState.create('')).toThrow('Invalid session state');
|
||||
expect(() => SessionState.create('' as any)).toThrow('Invalid session state');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user