diff --git a/api/src/nlp/repositories/nlp-entity.repository.spec.ts b/api/src/nlp/repositories/nlp-entity.repository.spec.ts index 8c77bc7b..76a99d4a 100644 --- a/api/src/nlp/repositories/nlp-entity.repository.spec.ts +++ b/api/src/nlp/repositories/nlp-entity.repository.spec.ts @@ -231,12 +231,13 @@ describe('NlpEntityRepository', () => { describe('postUpdate', () => { it('should update an NlpEntity and trigger a postUpdate event', async () => { + jest.spyOn(nlpService, 'handleEntityPostUpdate'); + jest.spyOn(llmNluHelper, 'updateEntity'); + nlpEntityRepository.eventEmitter.once( 'hook:nlpEntity:postUpdate', async (...[query, updated]) => { - jest.spyOn(llmNluHelper, 'updateEntity'); await nlpService.handleEntityPostUpdate(query, updated); - expect(llmNluHelper.updateEntity).toHaveBeenCalledWith(updated); }, ); @@ -247,6 +248,10 @@ describe('NlpEntityRepository', () => { }, { value: 'test3' }, ); + + expect(nlpService.handleEntityPostUpdate).toHaveBeenCalledTimes(1); + expect(llmNluHelper.updateEntity).toHaveBeenCalledTimes(1); + const result = await nlpEntityRepository.findOne(updatedNlpEntity.id); expect(result).toEqualPayload(updatedNlpEntity); diff --git a/api/src/nlp/repositories/nlp-value.repository.spec.ts b/api/src/nlp/repositories/nlp-value.repository.spec.ts index 5774407e..7cc9a482 100644 --- a/api/src/nlp/repositories/nlp-value.repository.spec.ts +++ b/api/src/nlp/repositories/nlp-value.repository.spec.ts @@ -253,10 +253,12 @@ describe('NlpValueRepository', () => { describe('postUpdate', () => { it('should update an NlpValue and trigger a postUpdate event', async () => { + jest.spyOn(nlpService, 'handleValuePostUpdate'); + jest.spyOn(llmNluHelper, 'updateValue'); + nlpValueRepository.eventEmitter.once( 'hook:nlpValue:postUpdate', async (...[query, updated]) => { - jest.spyOn(llmNluHelper, 'updateValue'); await nlpService.handleValuePostUpdate(query, updated); expect(llmNluHelper.updateValue).toHaveBeenCalledWith(updated); @@ -269,6 +271,10 @@ describe('NlpValueRepository', () => { }, { value: 'test2' }, ); + + expect(nlpService.handleValuePostUpdate).toHaveBeenCalledTimes(1); + expect(llmNluHelper.updateValue).toHaveBeenCalledTimes(1); + const result = await nlpValueRepository.findOne(updatedNlpValue.id); expect(result).toEqualPayload(updatedNlpValue);