website refactor

This commit is contained in:
2026-01-16 15:20:25 +01:00
parent 7e02fc3ea5
commit 37b1aa626c
325 changed files with 2167 additions and 2782 deletions

View File

@@ -6,8 +6,6 @@ import {
type GetLeagueStandingsResult,
type GetLeagueStandingsErrorCode,
} from './GetLeagueStandingsUseCase';
import type { StandingRepository } from '../../domain/repositories/StandingRepository';
import type { DriverRepository } from '../../domain/repositories/DriverRepository';
import { Standing } from '../../domain/entities/Standing';
import { Driver } from '../../domain/entities/Driver';
@@ -19,6 +17,7 @@ describe('GetLeagueStandingsUseCase', () => {
let driverRepository: {
findById: Mock;
};
beforeEach(() => {
standingRepository = {
findByLeagueId: vi.fn(),
@@ -26,15 +25,12 @@ describe('GetLeagueStandingsUseCase', () => {
driverRepository = {
findById: vi.fn(),
};
output = {
present: vi.fn(),
};
useCase = new GetLeagueStandingsUseCase(standingRepository as unknown as IStandingRepository,
driverRepository as unknown as IDriverRepository);
useCase = new GetLeagueStandingsUseCase(standingRepository as any,
driverRepository as any);
});
it('should present standings with drivers mapped and return ok result', async () => {
it('should return standings with drivers mapped', async () => {
const leagueId = 'league-1';
const standings = [
Standing.create({
@@ -75,9 +71,9 @@ describe('GetLeagueStandingsUseCase', () => {
const result = await useCase.execute({ leagueId } satisfies GetLeagueStandingsInput);
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const presented = result.unwrap();
const presented = expect(presented.standings).toHaveLength(2);
expect(presented.standings).toHaveLength(2);
expect(presented.standings[0]).toEqual({
driverId: 'driver-1',
driver: driver1,
@@ -92,7 +88,7 @@ describe('GetLeagueStandingsUseCase', () => {
});
});
it('should return repository error and not call output when repository fails', async () => {
it('should return repository error when repository fails', async () => {
const leagueId = 'league-1';
standingRepository.findByLeagueId.mockRejectedValue(new Error('DB error'));
@@ -106,5 +102,5 @@ describe('GetLeagueStandingsUseCase', () => {
expect(error.code).toBe('REPOSITORY_ERROR');
expect(error.details.message).toBe('DB error');
});
});
});
});