refactor use cases
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import { beforeEach, describe, expect, it, Mock, vi } from 'vitest';
|
||||
import type { IGameRepository } from '../../domain/repositories/IGameRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
@@ -17,8 +16,6 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => {
|
||||
let mockSeasonRepo: { findByLeagueId: Mock };
|
||||
let mockScoringConfigRepo: { findBySeasonId: Mock };
|
||||
let mockGameRepo: { findById: Mock };
|
||||
let output: UseCaseOutputPort<GetAllLeaguesWithCapacityAndScoringResult> & { present: Mock };
|
||||
|
||||
beforeEach(() => {
|
||||
mockLeagueRepo = { findAll: vi.fn() };
|
||||
mockMembershipRepo = { getLeagueMembers: vi.fn() };
|
||||
@@ -29,8 +26,7 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => {
|
||||
});
|
||||
|
||||
it('should return enriched leagues with capacity and scoring', async () => {
|
||||
const useCase = new GetAllLeaguesWithCapacityAndScoringUseCase(
|
||||
mockLeagueRepo as unknown as ILeagueRepository,
|
||||
const useCase = new GetAllLeaguesWithCapacityAndScoringUseCase(mockLeagueRepo as unknown as ILeagueRepository,
|
||||
mockMembershipRepo as unknown as ILeagueMembershipRepository,
|
||||
mockSeasonRepo as unknown as ISeasonRepository,
|
||||
mockScoringConfigRepo as unknown as ILeagueScoringConfigRepository,
|
||||
@@ -59,12 +55,8 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => {
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(result.unwrap()).toBeUndefined();
|
||||
|
||||
expect(output.present).toHaveBeenCalledTimes(1);
|
||||
|
||||
const presented =
|
||||
output.present.mock.calls[0]?.[0] as GetAllLeaguesWithCapacityAndScoringResult;
|
||||
|
||||
expect(presented?.leagues).toHaveLength(1);
|
||||
expect(presented?.leagues).toHaveLength(1);
|
||||
|
||||
const [summary] = presented?.leagues ?? [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user