From bfc731bd961601120ced7dbc848e0aaa95c8c911 Mon Sep 17 00:00:00 2001 From: Fanch Date: Thu, 23 May 2024 07:19:39 +0200 Subject: [PATCH] test(ad pause): fix test after adding update event emission --- tests/unit/ad/core/pause-ad.service.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit/ad/core/pause-ad.service.spec.ts b/tests/unit/ad/core/pause-ad.service.spec.ts index ad74eed..243f292 100644 --- a/tests/unit/ad/core/pause-ad.service.spec.ts +++ b/tests/unit/ad/core/pause-ad.service.spec.ts @@ -2,6 +2,7 @@ import { AD_REPOSITORY } from '@modules/ad/ad.di-tokens'; import { PauseAdCommand } from '@modules/ad/core/application/commands/pause-ad/pause-ad.command'; import { PauseAdService } from '@modules/ad/core/application/commands/pause-ad/pause-ad.service'; import { AdEntity } from '@modules/ad/core/domain/ad.entity'; +import { EventEmitter2 } from '@nestjs/event-emitter'; import { Test, TestingModule } from '@nestjs/testing'; import { punctualPassengerCreateAdProps } from './ad.fixtures'; @@ -13,6 +14,10 @@ const mockAdRepository = { update: jest.fn(), }; +const mockEventEmitter = { + emitAsync: jest.fn(), +}; + describe('pause-ad.service', () => { let pauseAdService: PauseAdService; @@ -23,6 +28,10 @@ describe('pause-ad.service', () => { provide: AD_REPOSITORY, useValue: mockAdRepository, }, + { + provide: EventEmitter2, + useValue: mockEventEmitter, + }, PauseAdService, ], }).compile(); @@ -37,6 +46,6 @@ describe('pause-ad.service', () => { it('should trigger the pause logic and pause the ad from the repository', async () => { await pauseAdService.execute(new PauseAdCommand({ id: ad.id })); expect(ad.pause).toHaveBeenCalled(); - expect(mockAdRepository.update).toHaveBeenCalledWith(ad); + expect(mockAdRepository.update).toHaveBeenCalled(); }); });