refactor driver module (wip)

This commit is contained in:
2025-12-22 10:24:40 +01:00
parent e7dbec4a85
commit 9da528d5bd
108 changed files with 842 additions and 947 deletions

View File

@@ -1,4 +1,3 @@
import { Result } from '@core/shared/application/Result';
import { GetAllRacesPresenter } from './GetAllRacesPresenter';
import type { GetAllRacesResult } from '@core/racing/application/use-cases/GetAllRacesUseCase';
@@ -6,7 +5,7 @@ describe('GetAllRacesPresenter', () => {
it('should map races and distinct leagues into the DTO', async () => {
const presenter = new GetAllRacesPresenter();
const output: GetAllRacesOutputPort = {
const output: GetAllRacesResult = {
races: [
{
id: 'race-1',
@@ -14,9 +13,8 @@ describe('GetAllRacesPresenter', () => {
track: 'Track A',
car: 'Car A',
status: 'scheduled',
scheduledAt: '2025-01-01T10:00:00.000Z',
scheduledAt: new Date('2025-01-01T10:00:00.000Z'),
strengthOfField: 1500,
leagueName: 'League One',
},
{
id: 'race-2',
@@ -24,9 +22,8 @@ describe('GetAllRacesPresenter', () => {
track: 'Track B',
car: 'Car B',
status: 'completed',
scheduledAt: '2025-01-02T10:00:00.000Z',
strengthOfField: null,
leagueName: 'League One',
scheduledAt: new Date('2025-01-02T10:00:00.000Z'),
strengthOfField: undefined,
},
{
id: 'race-3',
@@ -34,16 +31,22 @@ describe('GetAllRacesPresenter', () => {
track: 'Track C',
car: 'Car C',
status: 'running',
scheduledAt: '2025-01-03T10:00:00.000Z',
scheduledAt: new Date('2025-01-03T10:00:00.000Z'),
strengthOfField: 1800,
leagueName: 'League Two',
},
],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
] as any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
leagues: [
{ id: 'league-1', name: 'League One' },
{ id: 'league-2', name: 'League Two' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
] as any,
totalCount: 3,
};
await presenter.present(output);
const viewModel = presenter.getViewModel();
const viewModel = presenter.getResponseModel();
expect(viewModel).not.toBeNull();
expect(viewModel!.races).toHaveLength(3);
@@ -61,13 +64,16 @@ describe('GetAllRacesPresenter', () => {
it('should handle empty races by returning empty leagues', async () => {
const presenter = new GetAllRacesPresenter();
const output: GetAllRacesOutputPort = {
races: [],
const output: GetAllRacesResult = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
races: [] as any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
leagues: [] as any,
totalCount: 0,
};
await presenter.present(output);
const viewModel = presenter.getViewModel();
const viewModel = presenter.getResponseModel();
expect(viewModel).not.toBeNull();
expect(viewModel!.races).toHaveLength(0);