Files
gridpilot.gg/adapters/bootstrap/racing/RacingDriverFactory.ts
2025-12-27 01:53:36 +01:00

26 lines
835 B
TypeScript

import { Driver } from '@core/racing/domain/entities/Driver';
import { faker } from '@faker-js/faker';
export class RacingDriverFactory {
constructor(
private readonly driverCount: number,
private readonly baseDate: Date,
) {}
create(): Driver[] {
const countries = ['DE', 'NL', 'FR', 'GB', 'US', 'CA', 'SE', 'NO', 'IT', 'ES', 'AU', 'BR', 'JP', 'KR', 'RU', 'PL', 'CZ', 'HU', 'AT', 'CH'] as const;
return Array.from({ length: this.driverCount }, (_, idx) => {
const i = idx + 1;
return Driver.create({
id: `driver-${i}`,
iracingId: String(100000 + i),
name: faker.person.fullName(),
country: faker.helpers.arrayElement(countries),
bio: faker.lorem.sentences(2),
joinedAt: faker.date.past({ years: 2, refDate: this.baseDate }),
});
});
}
}