@@ -2,8 +2,8 @@ import { Test, TestingModule } from '@nestjs/testing';
22import { BadRequestException , NotFoundException } from '@nestjs/common' ;
33import { PaymentsService } from './payments.service' ;
44import { PrismaService } from '../prisma/prisma.service' ;
5- import { LimitsService } from '../limits/limits.service' ;
65import { WalletsService } from '../wallets/wallets.service' ;
6+ import { PAYMENT_LIMITS_PORT } from './ports/payment-limits.port' ;
77import { WalletStatus } from '../wallets/domain/wallet.model' ;
88import { PaymentStatus } from './entities/payment.entity' ;
99
@@ -26,7 +26,7 @@ const BASE_DTO = {
2626describe ( 'PaymentsService' , ( ) => {
2727 let service : PaymentsService ;
2828 let prisma : any ;
29- let limitsService : any ;
29+ let paymentLimitsPort : any ;
3030 let walletsService : any ;
3131
3232 beforeEach ( async ( ) => {
@@ -39,14 +39,14 @@ describe('PaymentsService', () => {
3939 count : jest . fn ( ) ,
4040 } ,
4141 } ;
42- limitsService = { checkLimits : jest . fn ( ) } ;
42+ paymentLimitsPort = { checkLimits : jest . fn ( ) } ;
4343 walletsService = { findWalletById : jest . fn ( ) } ;
4444
4545 const module : TestingModule = await Test . createTestingModule ( {
4646 providers : [
4747 PaymentsService ,
4848 { provide : PrismaService , useValue : prisma } ,
49- { provide : LimitsService , useValue : limitsService } ,
49+ { provide : PAYMENT_LIMITS_PORT , useValue : paymentLimitsPort } ,
5050 { provide : WalletsService , useValue : walletsService } ,
5151 ] ,
5252 } ) . compile ( ) ;
@@ -63,7 +63,7 @@ describe('PaymentsService', () => {
6363 walletsService . findWalletById
6464 . mockResolvedValueOnce ( ACTIVE_WALLET )
6565 . mockResolvedValueOnce ( RECEIVER_WALLET ) ;
66- limitsService . checkLimits . mockResolvedValue ( undefined ) ;
66+ paymentLimitsPort . checkLimits . mockResolvedValue ( undefined ) ;
6767 prisma . payment . create . mockResolvedValue ( {
6868 id : 1 ,
6969 ...BASE_DTO ,
@@ -78,7 +78,7 @@ describe('PaymentsService', () => {
7878 expect ( walletsService . findWalletById ) . toHaveBeenCalledWith (
7979 BASE_DTO . receiverWalletId ,
8080 ) ;
81- expect ( limitsService . checkLimits ) . toHaveBeenCalledWith (
81+ expect ( paymentLimitsPort . checkLimits ) . toHaveBeenCalledWith (
8282 BASE_DTO . walletId ,
8383 BASE_DTO . amount ,
8484 ) ;
@@ -151,7 +151,7 @@ describe('PaymentsService', () => {
151151 walletsService . findWalletById
152152 . mockResolvedValueOnce ( ACTIVE_WALLET )
153153 . mockResolvedValueOnce ( RECEIVER_WALLET ) ;
154- limitsService . checkLimits . mockResolvedValue ( undefined ) ;
154+ paymentLimitsPort . checkLimits . mockResolvedValue ( undefined ) ;
155155 prisma . payment . create . mockResolvedValue ( {
156156 id : 1 ,
157157 ...BASE_DTO ,
@@ -160,7 +160,7 @@ describe('PaymentsService', () => {
160160
161161 await service . create ( BASE_DTO ) ;
162162
163- expect ( limitsService . checkLimits ) . toHaveBeenCalledWith (
163+ expect ( paymentLimitsPort . checkLimits ) . toHaveBeenCalledWith (
164164 BASE_DTO . walletId ,
165165 BASE_DTO . amount ,
166166 ) ;
0 commit comments