import { describe, it, expect } from 'vitest'; import { RaceResultGeneratorWithIncidents } from './RaceResultGeneratorWithIncidents'; import { RaceIncidents } from '../../domain/value-objects/RaceIncidents'; describe('RaceResultGeneratorWithIncidents', () => { it('should generate results for all drivers', () => { const raceId = 'race-1'; const driverIds = ['d1', 'd2']; const driverRatings = new Map([ ['d1', 2000], ['d2', 1500], ]); const results = RaceResultGeneratorWithIncidents.generateRaceResults(raceId, driverIds, driverRatings); expect(results).toHaveLength(2); results.forEach(r => { expect(r.raceId.toString()).toBe(raceId); expect(r.incidents).toBeInstanceOf(RaceIncidents); }); }); it('should calculate incident penalty points', () => { const incidents = new RaceIncidents([ { type: 'contact', lap: 1, description: 'desc', penaltyPoints: 2 }, { type: 'unsafe_rejoin', lap: 5, description: 'desc', penaltyPoints: 3 }, ]); expect(RaceResultGeneratorWithIncidents.getIncidentPenaltyPoints(incidents)).toBe(5); }); it('should get incident description', () => { const incidents = new RaceIncidents([ { type: 'contact', lap: 1, description: 'desc', penaltyPoints: 2 }, ]); const description = RaceResultGeneratorWithIncidents.getIncidentDescription(incidents); expect(description).toContain('1 incidents'); }); });