website refactor

This commit is contained in:
2026-01-16 18:21:06 +01:00
parent 2f53727702
commit 095885544b
146 changed files with 970 additions and 524 deletions

View File

@@ -1,5 +1,5 @@
import type { Logger } from '@core/shared/domain/Logger';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
import { League } from '../../domain/entities/League';
import { Race } from '../../domain/entities/Race';
import {
@@ -7,9 +7,24 @@ import {
type GetAllRacesPageDataInput
} from './GetAllRacesPageDataUseCase';
import { RaceRepository } from '../../domain/repositories/RaceRepository';
import { LeagueRepository } from '../../domain/repositories/LeagueRepository';
describe('GetAllRacesPageDataUseCase', () => {
const mockRaceFindAll = vi.fn();
const mockRaceRepo: any = {
const mockRaceRepo: {
findById: Mock;
findAll: Mock;
findByLeagueId: Mock;
findUpcomingByLeagueId: Mock;
findCompletedByLeagueId: Mock;
findByStatus: Mock;
findByDateRange: Mock;
create: Mock;
update: Mock;
delete: Mock;
exists: Mock;
} = {
findById: vi.fn(),
findAll: mockRaceFindAll,
findByLeagueId: vi.fn(),
@@ -24,7 +39,16 @@ describe('GetAllRacesPageDataUseCase', () => {
};
const mockLeagueFindAll = vi.fn();
const mockLeagueRepo: any = {
const mockLeagueRepo: {
findById: Mock;
findAll: Mock;
findByOwnerId: Mock;
create: Mock;
update: Mock;
delete: Mock;
exists: Mock;
searchByName: Mock;
} = {
findById: vi.fn(),
findAll: mockLeagueFindAll,
findByOwnerId: vi.fn(),
@@ -47,9 +71,11 @@ describe('GetAllRacesPageDataUseCase', () => {
});
it('should return races and filters data', async () => {
const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo,
mockLeagueRepo,
mockLogger);
const useCase = new GetAllRacesPageDataUseCase(
mockRaceRepo as unknown as RaceRepository,
mockLeagueRepo as unknown as LeagueRepository,
mockLogger
);
const race1 = Race.create({
id: 'race1',
@@ -132,9 +158,11 @@ describe('GetAllRacesPageDataUseCase', () => {
});
it('should return empty result when no races or leagues', async () => {
const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo,
mockLeagueRepo,
mockLogger);
const useCase = new GetAllRacesPageDataUseCase(
mockRaceRepo as unknown as RaceRepository,
mockLeagueRepo as unknown as LeagueRepository,
mockLogger
);
mockRaceFindAll.mockResolvedValue([]);
mockLeagueFindAll.mockResolvedValue([]);
@@ -157,9 +185,11 @@ describe('GetAllRacesPageDataUseCase', () => {
});
it('should return error when repository throws', async () => {
const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo,
mockLeagueRepo,
mockLogger);
const useCase = new GetAllRacesPageDataUseCase(
mockRaceRepo as unknown as RaceRepository,
mockLeagueRepo as unknown as LeagueRepository,
mockLogger
);
const error = new Error('Repository error');
mockRaceFindAll.mockRejectedValue(error);