@@ -3,7 +3,6 @@ import { BadRequestException, NotFoundException } from '@nestjs/common';
33import { EventEmitter2 } from '@nestjs/event-emitter' ;
44import { PaymentsService } from './payments.service' ;
55import { PrismaService } from '../prisma/prisma.service' ;
6- import { LimitsService } from '../limits/limits.service' ;
76import { WalletsService } from '../wallets/wallets.service' ;
87import { MetricsService } from '../metrics/metrics.service' ;
98import { WalletStatus } from '../wallets/domain/wallet.model' ;
@@ -31,7 +30,7 @@ const BASE_DTO = {
3130describe ( 'PaymentsService' , ( ) => {
3231 let service : PaymentsService ;
3332 let prisma : any ;
34- let limitsService : any ;
33+ let paymentLimitsPort : any ;
3534 let walletsService : any ;
3635 let eventEmitter : any ;
3736 let metrics : any ;
@@ -46,7 +45,7 @@ describe('PaymentsService', () => {
4645 count : jest . fn ( ) ,
4746 } ,
4847 } ;
49- limitsService = { checkLimits : jest . fn ( ) } ;
48+ paymentLimitsPort = { checkLimits : jest . fn ( ) } ;
5049 walletsService = { findWalletById : jest . fn ( ) } ;
5150 eventEmitter = { emit : jest . fn ( ) } ;
5251 metrics = {
@@ -59,7 +58,7 @@ describe('PaymentsService', () => {
5958 providers : [
6059 PaymentsService ,
6160 { provide : PrismaService , useValue : prisma } ,
62- { provide : LimitsService , useValue : limitsService } ,
61+ { provide : PAYMENT_LIMITS_PORT , useValue : paymentLimitsPort } ,
6362 { provide : WalletsService , useValue : walletsService } ,
6463 { provide : EventEmitter2 , useValue : eventEmitter } ,
6564 { provide : MetricsService , useValue : metrics } ,
@@ -78,7 +77,7 @@ describe('PaymentsService', () => {
7877 walletsService . findWalletById
7978 . mockResolvedValueOnce ( ACTIVE_WALLET )
8079 . mockResolvedValueOnce ( RECEIVER_WALLET ) ;
81- limitsService . checkLimits . mockResolvedValue ( undefined ) ;
80+ paymentLimitsPort . checkLimits . mockResolvedValue ( undefined ) ;
8281 prisma . payment . create . mockResolvedValue ( {
8382 id : 1 ,
8483 ...BASE_DTO ,
@@ -93,7 +92,7 @@ describe('PaymentsService', () => {
9392 expect ( walletsService . findWalletById ) . toHaveBeenCalledWith (
9493 BASE_DTO . receiverWalletId ,
9594 ) ;
96- expect ( limitsService . checkLimits ) . toHaveBeenCalledWith (
95+ expect ( paymentLimitsPort . checkLimits ) . toHaveBeenCalledWith (
9796 BASE_DTO . walletId ,
9897 BASE_DTO . amount ,
9998 ) ;
@@ -166,7 +165,7 @@ describe('PaymentsService', () => {
166165 walletsService . findWalletById
167166 . mockResolvedValueOnce ( ACTIVE_WALLET )
168167 . mockResolvedValueOnce ( RECEIVER_WALLET ) ;
169- limitsService . checkLimits . mockResolvedValue ( undefined ) ;
168+ paymentLimitsPort . checkLimits . mockResolvedValue ( undefined ) ;
170169 prisma . payment . create . mockResolvedValue ( {
171170 id : 1 ,
172171 ...BASE_DTO ,
@@ -175,7 +174,7 @@ describe('PaymentsService', () => {
175174
176175 await service . create ( BASE_DTO ) ;
177176
178- expect ( limitsService . checkLimits ) . toHaveBeenCalledWith (
177+ expect ( paymentLimitsPort . checkLimits ) . toHaveBeenCalledWith (
179178 BASE_DTO . walletId ,
180179 BASE_DTO . amount ,
181180 ) ;
0 commit comments