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

@@ -1,3 +1,4 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { Result } from '@core/shared/domain/Result';
import { GetLeagueScoringConfigUseCase } from './GetLeagueScoringConfigUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
@@ -12,39 +13,39 @@ import type { LeagueScoringPreset } from '../../domain/types/LeagueScoringPreset
describe('GetLeagueScoringConfigUseCase', () => {
let useCase: GetLeagueScoringConfigUseCase;
let mockLeagueRepository: jest.Mocked<ILeagueRepository>;
let mockSeasonRepository: jest.Mocked<ISeasonRepository>;
let mockLeagueScoringConfigRepository: jest.Mocked<ILeagueScoringConfigRepository>;
let mockGameRepository: jest.Mocked<IGameRepository>;
let mockPresetProvider: { getPresetById: jest.Mock };
let mockLeagueRepository: any;
let mockSeasonRepository: any;
let mockLeagueScoringConfigRepository: any;
let mockGameRepository: any;
let mockPresetProvider: { getPresetById: any };
beforeEach(() => {
mockLeagueRepository = {
findById: jest.fn(),
exists: jest.fn(),
save: jest.fn(),
findAll: jest.fn(),
} as any;
findById: vi.fn(),
exists: vi.fn(),
save: vi.fn(),
findAll: vi.fn(),
};
mockSeasonRepository = {
findByLeagueId: jest.fn(),
save: jest.fn(),
findById: jest.fn(),
} as any;
findByLeagueId: vi.fn(),
save: vi.fn(),
findById: vi.fn(),
};
mockLeagueScoringConfigRepository = {
findBySeasonId: jest.fn(),
save: jest.fn(),
} as any;
findBySeasonId: vi.fn(),
save: vi.fn(),
};
mockGameRepository = {
findById: jest.fn(),
save: jest.fn(),
findAll: jest.fn(),
} as any;
findById: vi.fn(),
save: vi.fn(),
findAll: vi.fn(),
};
mockPresetProvider = {
getPresetById: jest.fn(),
getPresetById: vi.fn(),
};
useCase = new GetLeagueScoringConfigUseCase(
@@ -80,7 +81,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isOk()).toBe(true);
const value = result.value as any;
const value = result.unwrap() as any;
expect(value.league).toBe(mockLeague);
expect(value.season).toBe(mockSeason);
expect(value.scoringConfig).toBe(mockScoringConfig);
@@ -94,7 +95,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'non-existent' });
expect(result.isErr()).toBe(true);
expect(result.value).toEqual({
expect(result.unwrapErr()).toEqual({
code: 'LEAGUE_NOT_FOUND',
details: { message: 'League not found' },
});
@@ -109,7 +110,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isErr()).toBe(true);
expect(result.value).toEqual({
expect(result.unwrapErr()).toEqual({
code: 'NO_SEASONS',
details: { message: 'No seasons found for league' },
});
@@ -129,7 +130,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isErr()).toBe(true);
expect(result.value).toEqual({
expect(result.unwrapErr()).toEqual({
code: 'NO_ACTIVE_SEASON',
details: { message: 'No active season found for league' },
});
@@ -150,7 +151,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isErr()).toBe(true);
expect(result.value).toEqual({
expect(result.unwrapErr()).toEqual({
code: 'NO_SCORING_CONFIG',
details: { message: 'Scoring configuration not found' },
});
@@ -177,7 +178,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isErr()).toBe(true);
expect(result.value).toEqual({
expect(result.unwrapErr()).toEqual({
code: 'GAME_NOT_FOUND',
details: { message: 'Game not found for season' },
});
@@ -205,7 +206,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isOk()).toBe(true);
const value = result.value as any;
const value = result.unwrap() as any;
expect(value.preset).toBeUndefined();
});
@@ -215,9 +216,9 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isErr()).toBe(true);
expect(result.value).toEqual({
expect(result.unwrapErr()).toEqual({
code: 'REPOSITORY_ERROR',
details: { message: 'Database error' },
});
});
});
});