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,18 +1,15 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import {
GetAllRacesPageDataUseCase,
type GetAllRacesPageDataResult,
type GetAllRacesPageDataInput,
} from './GetAllRacesPageDataUseCase';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { Logger } from '@core/shared/application';
import { Race } from '../../domain/entities/Race';
import type { Logger } from '@core/shared/domain/Logger';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { League } from '../../domain/entities/League';
import { Race } from '../../domain/entities/Race';
import {
GetAllRacesPageDataUseCase,
type GetAllRacesPageDataInput
} from './GetAllRacesPageDataUseCase';
describe('GetAllRacesPageDataUseCase', () => {
const mockRaceFindAll = vi.fn();
const mockRaceRepo: IRaceRepository = {
const mockRaceRepo: any = {
findById: vi.fn(),
findAll: mockRaceFindAll,
findByLeagueId: vi.fn(),
@@ -27,7 +24,7 @@ describe('GetAllRacesPageDataUseCase', () => {
};
const mockLeagueFindAll = vi.fn();
const mockLeagueRepo: ILeagueRepository = {
const mockLeagueRepo: any = {
findById: vi.fn(),
findAll: mockLeagueFindAll,
findByOwnerId: vi.fn(),
@@ -47,9 +44,9 @@ describe('GetAllRacesPageDataUseCase', () => {
beforeEach(() => {
vi.clearAllMocks();
});
});
it('should present races and filters data', async () => {
it('should return races and filters data', async () => {
const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo,
mockLeagueRepo,
mockLogger);
@@ -95,8 +92,8 @@ describe('GetAllRacesPageDataUseCase', () => {
const result = await useCase.execute(input);
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const presented = expect(presented.races).toEqual([
const presented = result.unwrap();
expect(presented.races).toEqual([
{
id: 'race2',
track: 'Track B',
@@ -134,7 +131,7 @@ describe('GetAllRacesPageDataUseCase', () => {
});
});
it('should present empty result when no races or leagues', async () => {
it('should return empty result when no races or leagues', async () => {
const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo,
mockLeagueRepo,
mockLogger);
@@ -145,8 +142,8 @@ describe('GetAllRacesPageDataUseCase', () => {
const result = await useCase.execute({});
expect(result.isOk()).toBe(true);
expect(result.unwrap()).toBeUndefined();
const presented = expect(presented.races).toEqual([]);
const presented = result.unwrap();
expect(presented.races).toEqual([]);
expect(presented.filters).toEqual({
statuses: [
{ value: 'all', label: 'All Statuses' },
@@ -159,7 +156,7 @@ describe('GetAllRacesPageDataUseCase', () => {
});
});
it('should return error when repository throws and not present data', async () => {
it('should return error when repository throws', async () => {
const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo,
mockLeagueRepo,
mockLogger);
@@ -173,5 +170,5 @@ describe('GetAllRacesPageDataUseCase', () => {
const err = result.unwrapErr();
expect(err.code).toBe('REPOSITORY_ERROR');
expect(err.details.message).toBe('Repository error');
});
});
});