mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): enhance postUpdate unit tests
This commit is contained in:
parent
6001fef761
commit
848a1b3767
@ -231,12 +231,13 @@ describe('NlpEntityRepository', () => {
|
|||||||
|
|
||||||
describe('postUpdate', () => {
|
describe('postUpdate', () => {
|
||||||
it('should update an NlpEntity and trigger a postUpdate event', async () => {
|
it('should update an NlpEntity and trigger a postUpdate event', async () => {
|
||||||
|
jest.spyOn(nlpService, 'handleEntityPostUpdate');
|
||||||
|
jest.spyOn(llmNluHelper, 'updateEntity');
|
||||||
|
|
||||||
nlpEntityRepository.eventEmitter.once(
|
nlpEntityRepository.eventEmitter.once(
|
||||||
'hook:nlpEntity:postUpdate',
|
'hook:nlpEntity:postUpdate',
|
||||||
async (...[query, updated]) => {
|
async (...[query, updated]) => {
|
||||||
jest.spyOn(llmNluHelper, 'updateEntity');
|
|
||||||
await nlpService.handleEntityPostUpdate(query, updated);
|
await nlpService.handleEntityPostUpdate(query, updated);
|
||||||
|
|
||||||
expect(llmNluHelper.updateEntity).toHaveBeenCalledWith(updated);
|
expect(llmNluHelper.updateEntity).toHaveBeenCalledWith(updated);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -247,6 +248,10 @@ describe('NlpEntityRepository', () => {
|
|||||||
},
|
},
|
||||||
{ value: 'test3' },
|
{ value: 'test3' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(nlpService.handleEntityPostUpdate).toHaveBeenCalledTimes(1);
|
||||||
|
expect(llmNluHelper.updateEntity).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
const result = await nlpEntityRepository.findOne(updatedNlpEntity.id);
|
const result = await nlpEntityRepository.findOne(updatedNlpEntity.id);
|
||||||
|
|
||||||
expect(result).toEqualPayload(updatedNlpEntity);
|
expect(result).toEqualPayload(updatedNlpEntity);
|
||||||
|
@ -253,10 +253,12 @@ describe('NlpValueRepository', () => {
|
|||||||
|
|
||||||
describe('postUpdate', () => {
|
describe('postUpdate', () => {
|
||||||
it('should update an NlpValue and trigger a postUpdate event', async () => {
|
it('should update an NlpValue and trigger a postUpdate event', async () => {
|
||||||
|
jest.spyOn(nlpService, 'handleValuePostUpdate');
|
||||||
|
jest.spyOn(llmNluHelper, 'updateValue');
|
||||||
|
|
||||||
nlpValueRepository.eventEmitter.once(
|
nlpValueRepository.eventEmitter.once(
|
||||||
'hook:nlpValue:postUpdate',
|
'hook:nlpValue:postUpdate',
|
||||||
async (...[query, updated]) => {
|
async (...[query, updated]) => {
|
||||||
jest.spyOn(llmNluHelper, 'updateValue');
|
|
||||||
await nlpService.handleValuePostUpdate(query, updated);
|
await nlpService.handleValuePostUpdate(query, updated);
|
||||||
|
|
||||||
expect(llmNluHelper.updateValue).toHaveBeenCalledWith(updated);
|
expect(llmNluHelper.updateValue).toHaveBeenCalledWith(updated);
|
||||||
@ -269,6 +271,10 @@ describe('NlpValueRepository', () => {
|
|||||||
},
|
},
|
||||||
{ value: 'test2' },
|
{ value: 'test2' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(nlpService.handleValuePostUpdate).toHaveBeenCalledTimes(1);
|
||||||
|
expect(llmNluHelper.updateValue).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
const result = await nlpValueRepository.findOne(updatedNlpValue.id);
|
const result = await nlpValueRepository.findOne(updatedNlpValue.id);
|
||||||
|
|
||||||
expect(result).toEqualPayload(updatedNlpValue);
|
expect(result).toEqualPayload(updatedNlpValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user