@@ -11,6 +11,8 @@ import {
1111import { Donation as DomainDonation } from './mappers' ;
1212import { INestApplication , BadRequestException } from '@nestjs/common' ;
1313import request from 'supertest' ;
14+ import { AuthService } from '../auth/auth.service' ;
15+ import { UsersService } from '../users/users.service' ;
1416describe ( 'DonationsController' , ( ) => {
1517 let controller : DonationsController ;
1618 let service : DonationsService ;
@@ -41,6 +43,16 @@ describe('DonationsController', () => {
4143 findPaginated : jest . fn ( ) ,
4244 } ;
4345
46+ const mockAuthService = {
47+ getUser : jest
48+ . fn ( )
49+ . mockResolvedValue ( [ { Name : 'email' , Value : 'test@example.com' } ] ) ,
50+ } ;
51+
52+ const mockUsersService = {
53+ find : jest . fn ( ) . mockResolvedValue ( [ ] ) ,
54+ } ;
55+
4456 beforeEach ( async ( ) => {
4557 const module : TestingModule = await Test . createTestingModule ( {
4658 controllers : [ DonationsController ] ,
@@ -53,6 +65,14 @@ describe('DonationsController', () => {
5365 provide : DonationsRepository ,
5466 useValue : mockRepository ,
5567 } ,
68+ {
69+ provide : AuthService ,
70+ useValue : mockAuthService ,
71+ } ,
72+ {
73+ provide : UsersService ,
74+ useValue : mockUsersService ,
75+ } ,
5676 ] ,
5777 } ) . compile ( ) ;
5878
@@ -409,11 +429,23 @@ describe('Donation Integration', () => {
409429 } ) ,
410430 } ;
411431
432+ const mockAuthServiceIntegration = {
433+ getUser : jest
434+ . fn ( )
435+ . mockResolvedValue ( [ { Name : 'email' , Value : 'test@example.com' } ] ) ,
436+ } ;
437+
438+ const mockUsersServiceIntegration = {
439+ find : jest . fn ( ) . mockResolvedValue ( [ ] ) ,
440+ } ;
441+
412442 const moduleFixture : TestingModule = await Test . createTestingModule ( {
413443 controllers : [ DonationsController ] ,
414444 providers : [
415445 { provide : DonationsService , useValue : mockService } ,
416446 { provide : DonationsRepository , useValue : { } } ,
447+ { provide : AuthService , useValue : mockAuthServiceIntegration } ,
448+ { provide : UsersService , useValue : mockUsersServiceIntegration } ,
417449 ] ,
418450 } ) . compile ( ) ;
419451
0 commit comments