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

@@ -13,30 +13,23 @@ import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorC
describe('GetLeagueFullConfigUseCase', () => {
let useCase: GetLeagueFullConfigUseCase;
let leagueRepository: ILeagueRepository & { findById: ReturnType<typeof vi.fn> };
let seasonRepository: ISeasonRepository & { findByLeagueId: ReturnType<typeof vi.fn> };
let leagueScoringConfigRepository: ILeagueScoringConfigRepository & {
findBySeasonId: ReturnType<typeof vi.fn>;
};
let gameRepository: IGameRepository & { findById: ReturnType<typeof vi.fn> };
let leagueRepository: any;
let seasonRepository: any;
let leagueScoringConfigRepository: any;
let gameRepository: any;
beforeEach(() => {
leagueRepository = {
findById: vi.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
};
seasonRepository = {
findByLeagueId: vi.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
};
leagueScoringConfigRepository = {
findBySeasonId: vi.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
};
gameRepository = {
findById: vi.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
};
useCase = new GetLeagueFullConfigUseCase(leagueRepository,
@@ -78,9 +71,7 @@ describe('GetLeagueFullConfigUseCase', () => {
const result = await useCase.execute(input);
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const firstCall = const presented = firstCall[0] as GetLeagueFullConfigResult;
const presented = result.unwrap();
expect(presented.config.league).toEqual(mockLeague);
expect(presented.config.activeSeason).toEqual(mockSeasons[0]);
@@ -88,7 +79,7 @@ describe('GetLeagueFullConfigUseCase', () => {
expect(presented.config.game).toEqual(mockGame);
});
it('should return error when league not found and not call presenter', async () => {
it('should return error when league not found', async () => {
const input: GetLeagueFullConfigInput = { leagueId: 'league-1' };
leagueRepository.findById.mockResolvedValue(null);
@@ -103,7 +94,7 @@ describe('GetLeagueFullConfigUseCase', () => {
expect(error.code).toBe('LEAGUE_NOT_FOUND');
expect(error.details.message).toBe('League not found');
});
});
it('should handle no active season', async () => {
const input: GetLeagueFullConfigInput = { leagueId: 'league-1' };
@@ -121,8 +112,7 @@ describe('GetLeagueFullConfigUseCase', () => {
const result = await useCase.execute(input);
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const firstCall = const presented = firstCall[0] as GetLeagueFullConfigResult;
const presented = result.unwrap();
expect(presented.config.league).toEqual(mockLeague);
expect(presented.config.activeSeason).toBeUndefined();
@@ -130,7 +120,7 @@ describe('GetLeagueFullConfigUseCase', () => {
expect(presented.config.game).toBeUndefined();
});
it('should return repository error when repository throws and not call presenter', async () => {
it('should return repository error when repository throws', async () => {
const input: GetLeagueFullConfigInput = { leagueId: 'league-1' };
const thrownError = new Error('Repository failure');
@@ -146,5 +136,5 @@ describe('GetLeagueFullConfigUseCase', () => {
expect(error.code).toBe('REPOSITORY_ERROR');
expect(error.details.message).toBe('Repository failure');
});
});
});