mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): enhance NlpValue postUpdate unit tests
This commit is contained in:
parent
3ce40840f6
commit
2d133450f1
@ -228,4 +228,28 @@ describe('NlpEntityRepository', () => {
|
||||
expect(intentNlpEntity).toEqualPayload(result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('postUpdate', () => {
|
||||
it('should update an NlpValue and trigger a postUpdate event', async () => {
|
||||
nlpEntityRepository.eventEmitter.once(
|
||||
'hook:nlpEntity:postUpdate',
|
||||
async (...[query, updated]) => {
|
||||
const spy1 = jest.spyOn(llmNluHelper, 'updateEntity');
|
||||
await nlpService.handleEntityPostUpdate(query, updated);
|
||||
|
||||
expect(spy1).toHaveBeenCalledWith(updated);
|
||||
},
|
||||
);
|
||||
|
||||
const updatedNlpEntity = await nlpEntityRepository.updateOne(
|
||||
{
|
||||
name: 'test2',
|
||||
},
|
||||
{ value: 'test3' },
|
||||
);
|
||||
const result = await nlpEntityRepository.findOne(updatedNlpEntity.id);
|
||||
|
||||
expect(result).toEqualPayload(updatedNlpEntity);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -250,4 +250,28 @@ describe('NlpValueRepository', () => {
|
||||
expect(intentNlpEntity).toEqualPayload(result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('postUpdate', () => {
|
||||
it('should update an NlpValue and trigger a postUpdate event', async () => {
|
||||
nlpValueRepository.eventEmitter.once(
|
||||
'hook:nlpValue:postUpdate',
|
||||
async (...[query, updated]) => {
|
||||
const spy1 = jest.spyOn(llmNluHelper, 'updateValue');
|
||||
await nlpService.handleValuePostUpdate(query, updated);
|
||||
|
||||
expect(spy1).toHaveBeenCalledWith(updated);
|
||||
},
|
||||
);
|
||||
|
||||
const updatedNlpEntity = await nlpValueRepository.updateOne(
|
||||
{
|
||||
value: 'test',
|
||||
},
|
||||
{ value: 'test2' },
|
||||
);
|
||||
const result = await nlpValueRepository.findOne(updatedNlpEntity.id);
|
||||
|
||||
expect(result).toEqualPayload(updatedNlpEntity);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user