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

@@ -5,8 +5,8 @@ import {
type GetLeagueStatsResult,
type GetLeagueStatsErrorCode,
} from './GetLeagueStatsUseCase';
import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
import { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
describe('GetLeagueStatsUseCase', () => {
@@ -18,6 +18,7 @@ describe('GetLeagueStatsUseCase', () => {
findByLeagueId: Mock;
};
let getDriverRating: Mock;
beforeEach(() => {
leagueMembershipRepository = {
getLeagueMembers: vi.fn(),
@@ -26,8 +27,8 @@ describe('GetLeagueStatsUseCase', () => {
findByLeagueId: vi.fn(),
};
getDriverRating = vi.fn();
useCase = new GetLeagueStatsUseCase(leagueMembershipRepository as unknown as ILeagueMembershipRepository,
raceRepository as unknown as IRaceRepository,
useCase = new GetLeagueStatsUseCase(leagueMembershipRepository as any,
raceRepository as any,
getDriverRating);
});
@@ -52,8 +53,8 @@ describe('GetLeagueStatsUseCase', () => {
const result = await useCase.execute(input);
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const presented = (expect(presented.leagueId).toBe(input.leagueId);
const presented = result.unwrap();
expect(presented.leagueId).toBe(input.leagueId);
expect(presented.driverCount).toBe(3);
expect(presented.raceCount).toBe(2);
expect(presented.averageRating).toBe(1550); // (1500 + 1600) / 2
@@ -71,8 +72,8 @@ describe('GetLeagueStatsUseCase', () => {
const result = await useCase.execute(input);
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const presented = (expect(presented.leagueId).toBe(input.leagueId);
const presented = result.unwrap();
expect(presented.leagueId).toBe(input.leagueId);
expect(presented.driverCount).toBe(1);
expect(presented.raceCount).toBe(1);
expect(presented.averageRating).toBe(0);
@@ -92,7 +93,7 @@ describe('GetLeagueStatsUseCase', () => {
>;
expect(error.code).toBe('LEAGUE_NOT_FOUND');
expect(error.details.message).toBe('League not found');
});
});
it('should return error when repository fails', async () => {
const input: GetLeagueStatsInput = { leagueId: 'league-1' };
@@ -107,5 +108,5 @@ describe('GetLeagueStatsUseCase', () => {
>;
expect(error.code).toBe('REPOSITORY_ERROR');
expect(error.details.message).toBe('DB error');
});
});
});