refactor use cases
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user