website refactor
This commit is contained in:
@@ -16,23 +16,23 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => {
|
||||
let mockSeasonRepo: { findByLeagueId: Mock };
|
||||
let mockScoringConfigRepo: { findBySeasonId: Mock };
|
||||
let mockGameRepo: { findById: Mock };
|
||||
|
||||
beforeEach(() => {
|
||||
mockLeagueRepo = { findAll: vi.fn() };
|
||||
mockMembershipRepo = { getLeagueMembers: vi.fn() };
|
||||
mockSeasonRepo = { findByLeagueId: vi.fn() };
|
||||
mockScoringConfigRepo = { findBySeasonId: vi.fn() };
|
||||
mockGameRepo = { findById: vi.fn() };
|
||||
output = { present: vi.fn() } as unknown as typeof output;
|
||||
});
|
||||
|
||||
it('should return enriched leagues with capacity and scoring', async () => {
|
||||
const useCase = new GetAllLeaguesWithCapacityAndScoringUseCase(mockLeagueRepo as unknown as ILeagueRepository,
|
||||
mockMembershipRepo as unknown as ILeagueMembershipRepository,
|
||||
mockSeasonRepo as unknown as ISeasonRepository,
|
||||
mockScoringConfigRepo as unknown as ILeagueScoringConfigRepository,
|
||||
mockGameRepo as unknown as IGameRepository,
|
||||
{ getPresetById: vi.fn().mockReturnValue({ id: 'preset1', name: 'Default' }) },
|
||||
output,
|
||||
const useCase = new GetAllLeaguesWithCapacityAndScoringUseCase(
|
||||
mockLeagueRepo as any,
|
||||
mockMembershipRepo as any,
|
||||
mockSeasonRepo as any,
|
||||
mockScoringConfigRepo as any,
|
||||
mockGameRepo as any,
|
||||
{ getPresetById: vi.fn().mockReturnValue({ id: 'preset1', name: 'Default' }) }
|
||||
);
|
||||
|
||||
const league = { id: 'league1', name: 'Test League', settings: { maxDrivers: 30 } };
|
||||
@@ -53,19 +53,18 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => {
|
||||
const result = await useCase.execute({} as GetAllLeaguesWithCapacityAndScoringInput);
|
||||
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(result.unwrap()).toBeUndefined();
|
||||
const presented = result.unwrap();
|
||||
|
||||
const presented =
|
||||
expect(presented?.leagues).toHaveLength(1);
|
||||
expect(presented.leagues).toHaveLength(1);
|
||||
|
||||
const [summary] = presented?.leagues ?? [];
|
||||
const summary = presented.leagues[0];
|
||||
|
||||
expect(summary?.league).toEqual(league);
|
||||
expect(summary?.currentDrivers).toBe(2);
|
||||
expect(summary?.maxDrivers).toBe(30);
|
||||
expect(summary?.season).toEqual(season);
|
||||
expect(summary?.scoringConfig).toEqual(scoringConfig);
|
||||
expect(summary?.game).toEqual(game);
|
||||
expect(summary?.preset).toEqual({ id: 'preset1', name: 'Default' });
|
||||
expect(summary.league).toEqual(league);
|
||||
expect(summary.currentDrivers).toBe(2);
|
||||
expect(summary.maxDrivers).toBe(30);
|
||||
expect(summary.season).toEqual(season);
|
||||
expect(summary.scoringConfig).toEqual(scoringConfig);
|
||||
expect(summary.game).toEqual(game);
|
||||
expect(summary.preset).toEqual({ id: 'preset1', name: 'Default' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user