adapter tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { InMemoryRaceRepository } from './InMemoryRaceRepository';
|
||||
import { RaceData } from '../../../../core/dashboard/application/ports/DashboardRepository';
|
||||
|
||||
describe('InMemoryRaceRepository', () => {
|
||||
let repository: InMemoryRaceRepository;
|
||||
|
||||
beforeEach(() => {
|
||||
repository = new InMemoryRaceRepository();
|
||||
});
|
||||
|
||||
describe('getUpcomingRaces', () => {
|
||||
it('should return empty array when no races for driver', async () => {
|
||||
// When
|
||||
const result = await repository.getUpcomingRaces('driver-1');
|
||||
|
||||
// Then
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('should return races when they exist', async () => {
|
||||
// Given
|
||||
const driverId = 'driver-1';
|
||||
const races: RaceData[] = [
|
||||
{
|
||||
id: 'race-1',
|
||||
trackName: 'Spa-Francorchamps',
|
||||
carType: 'GT3',
|
||||
scheduledDate: new Date(),
|
||||
},
|
||||
];
|
||||
repository.addUpcomingRaces(driverId, races);
|
||||
|
||||
// When
|
||||
const result = await repository.getUpcomingRaces(driverId);
|
||||
|
||||
// Then
|
||||
expect(result).toEqual(races);
|
||||
});
|
||||
|
||||
it('should overwrite races for same driver (idempotency)', async () => {
|
||||
// Given
|
||||
const driverId = 'driver-1';
|
||||
const races1: RaceData[] = [{ id: 'r1', trackName: 'T1', carType: 'C1', scheduledDate: new Date() }];
|
||||
const races2: RaceData[] = [{ id: 'r2', trackName: 'T2', carType: 'C2', scheduledDate: new Date() }];
|
||||
|
||||
// When
|
||||
repository.addUpcomingRaces(driverId, races1);
|
||||
repository.addUpcomingRaces(driverId, races2);
|
||||
const result = await repository.getUpcomingRaces(driverId);
|
||||
|
||||
// Then
|
||||
expect(result).toEqual(races2);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user