refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -2,15 +2,11 @@ import { describe, it, expect, vi, type Mock } from 'vitest';
import { GetPaymentsUseCase, type GetPaymentsInput } from './GetPaymentsUseCase';
import type { IPaymentRepository } from '../../domain/repositories/IPaymentRepository';
import { PaymentType, PayerType } from '../../domain/entities/Payment';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
describe('GetPaymentsUseCase', () => {
let paymentRepository: {
findByFilters: Mock;
};
let output: {
present: Mock;
};
let useCase: GetPaymentsUseCase;
beforeEach(() => {
@@ -18,17 +14,12 @@ describe('GetPaymentsUseCase', () => {
findByFilters: vi.fn(),
};
output = {
present: vi.fn(),
};
useCase = new GetPaymentsUseCase(
paymentRepository as unknown as IPaymentRepository,
output as unknown as UseCaseOutputPort<unknown>,
);
});
it('retrieves payments and presents the result', async () => {
it('retrieves payments and returns result', async () => {
const input: GetPaymentsInput = {
leagueId: 'league-1',
payerId: 'payer-1',
@@ -62,6 +53,9 @@ describe('GetPaymentsUseCase', () => {
payerId: 'payer-1',
type: PaymentType.SPONSORSHIP,
});
expect(output.present).toHaveBeenCalledWith({ payments });
if (result.isOk()) {
expect(result.value).toEqual({ payments });
}
});
});