refactor dtos to ports
This commit is contained in:
@@ -4,7 +4,6 @@ import type { ISponsorshipRequestRepository } from '../../domain/repositories/IS
|
||||
import type { ISeasonSponsorshipRepository } from '../../domain/repositories/ISeasonSponsorshipRepository';
|
||||
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
|
||||
import type { INotificationService } from '@core/notifications/application/ports/INotificationService';
|
||||
import type { IPaymentGateway } from '../ports/IPaymentGateway';
|
||||
import type { IWalletRepository } from '@core/payments/domain/repositories/IWalletRepository';
|
||||
import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueWalletRepository';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
@@ -27,9 +26,7 @@ describe('AcceptSponsorshipRequestUseCase', () => {
|
||||
let mockNotificationService: {
|
||||
sendNotification: Mock;
|
||||
};
|
||||
let mockPaymentGateway: {
|
||||
processPayment: Mock;
|
||||
};
|
||||
let processPayment: Mock;
|
||||
let mockWalletRepo: {
|
||||
findById: Mock;
|
||||
update: Mock;
|
||||
@@ -59,9 +56,7 @@ describe('AcceptSponsorshipRequestUseCase', () => {
|
||||
mockNotificationService = {
|
||||
sendNotification: vi.fn(),
|
||||
};
|
||||
mockPaymentGateway = {
|
||||
processPayment: vi.fn(),
|
||||
};
|
||||
processPayment = vi.fn();
|
||||
mockWalletRepo = {
|
||||
findById: vi.fn(),
|
||||
update: vi.fn(),
|
||||
@@ -84,7 +79,7 @@ describe('AcceptSponsorshipRequestUseCase', () => {
|
||||
mockSeasonSponsorshipRepo as unknown as ISeasonSponsorshipRepository,
|
||||
mockSeasonRepo as unknown as ISeasonRepository,
|
||||
mockNotificationService as unknown as INotificationService,
|
||||
mockPaymentGateway as unknown as IPaymentGateway,
|
||||
processPayment,
|
||||
mockWalletRepo as unknown as IWalletRepository,
|
||||
mockLeagueWalletRepo as unknown as ILeagueWalletRepository,
|
||||
mockLogger as unknown as Logger,
|
||||
@@ -112,7 +107,7 @@ describe('AcceptSponsorshipRequestUseCase', () => {
|
||||
mockSponsorshipRequestRepo.findById.mockResolvedValue(request);
|
||||
mockSeasonRepo.findById.mockResolvedValue(season);
|
||||
mockNotificationService.sendNotification.mockResolvedValue(undefined);
|
||||
mockPaymentGateway.processPayment.mockResolvedValue({
|
||||
processPayment.mockResolvedValue({
|
||||
success: true,
|
||||
transactionId: 'txn1',
|
||||
timestamp: new Date(),
|
||||
@@ -154,11 +149,13 @@ describe('AcceptSponsorshipRequestUseCase', () => {
|
||||
sponsorshipId: dto.sponsorshipId,
|
||||
},
|
||||
});
|
||||
expect(mockPaymentGateway.processPayment).toHaveBeenCalledWith(
|
||||
Money.create(1000),
|
||||
'sponsor1',
|
||||
'Sponsorship payment for season season1',
|
||||
{ requestId: 'req1' }
|
||||
expect(processPayment).toHaveBeenCalledWith(
|
||||
{
|
||||
amount: Money.create(1000),
|
||||
payerId: 'sponsor1',
|
||||
description: 'Sponsorship payment for season season1',
|
||||
metadata: { requestId: 'req1' }
|
||||
}
|
||||
);
|
||||
expect(mockWalletRepo.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user