mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): apply feedback
This commit is contained in:
parent
672342ca31
commit
6799f59e7b
@ -180,20 +180,20 @@ describe('NlpEntityRepository', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('postCreate', () => {
|
describe('postCreate', () => {
|
||||||
it('should not create and attached a foreign_id to the create nlp entity', async () => {
|
it('should create and attach a foreign_id to the newly created nlp entity', async () => {
|
||||||
nlpEntityRepository.eventEmitter.once(
|
nlpEntityRepository.eventEmitter.once(
|
||||||
'hook:nlpEntity:postCreate',
|
'hook:nlpEntity:postCreate',
|
||||||
async (...[created]) => {
|
async (...[created]) => {
|
||||||
const spy1 = jest.spyOn(llmNluHelper, 'addEntity');
|
const helperSpy = jest.spyOn(llmNluHelper, 'addEntity');
|
||||||
const spy2 = jest.spyOn(nlpEntityService, 'updateOne');
|
jest.spyOn(nlpEntityService, 'updateOne');
|
||||||
await nlpService.handleEntityPostCreate(created);
|
await nlpService.handleEntityPostCreate(created);
|
||||||
|
|
||||||
expect(spy1).toHaveBeenCalledWith(created);
|
expect(helperSpy).toHaveBeenCalledWith(created);
|
||||||
expect(spy2).toHaveBeenCalledWith(
|
expect(nlpEntityService.updateOne).toHaveBeenCalledWith(
|
||||||
{
|
{
|
||||||
_id: created._id,
|
_id: created._id,
|
||||||
},
|
},
|
||||||
{ foreign_id: await spy1.mock.results[0].value },
|
{ foreign_id: await helperSpy.mock.results[0].value },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -210,7 +210,7 @@ describe('NlpEntityRepository', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not create and attached a foreign_id to the create nlp entity with builtin true', async () => {
|
it('should not create and attach a foreign_id to the newly created nlp entity with builtin set to true', async () => {
|
||||||
nlpEntityRepository.eventEmitter.once(
|
nlpEntityRepository.eventEmitter.once(
|
||||||
'hook:nlpEntity:postCreate',
|
'hook:nlpEntity:postCreate',
|
||||||
async (...[created]) => {
|
async (...[created]) => {
|
||||||
|
@ -193,20 +193,20 @@ describe('NlpValueRepository', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('postCreate', () => {
|
describe('postCreate', () => {
|
||||||
it('should create and attached a foreign_id to the create nlp value', async () => {
|
it('should create and attach a foreign_id to the newly created nlp value', async () => {
|
||||||
nlpValueRepository.eventEmitter.once(
|
nlpValueRepository.eventEmitter.once(
|
||||||
'hook:nlpValue:postCreate',
|
'hook:nlpValue:postCreate',
|
||||||
async (...[created]) => {
|
async (...[created]) => {
|
||||||
const spy1 = jest.spyOn(llmNluHelper, 'addValue');
|
const helperSpy = jest.spyOn(llmNluHelper, 'addValue');
|
||||||
const spy2 = jest.spyOn(nlpValueService, 'updateOne');
|
jest.spyOn(nlpValueService, 'updateOne');
|
||||||
await nlpService.handleValuePostCreate(created);
|
await nlpService.handleValuePostCreate(created);
|
||||||
|
|
||||||
expect(spy1).toHaveBeenCalledWith(created);
|
expect(helperSpy).toHaveBeenCalledWith(created);
|
||||||
expect(spy2).toHaveBeenCalledWith(
|
expect(nlpValueService.updateOne).toHaveBeenCalledWith(
|
||||||
{
|
{
|
||||||
_id: created._id,
|
_id: created._id,
|
||||||
},
|
},
|
||||||
{ foreign_id: await spy1.mock.results[0].value },
|
{ foreign_id: await helperSpy.mock.results[0].value },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -228,7 +228,7 @@ describe('NlpValueRepository', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create and attached a foreign_id to the create nlp value with builtin true', async () => {
|
it('should not create and attach a foreign_id to the newly created nlp value with builtin set to true', async () => {
|
||||||
nlpValueRepository.eventEmitter.once(
|
nlpValueRepository.eventEmitter.once(
|
||||||
'hook:nlpValue:postCreate',
|
'hook:nlpValue:postCreate',
|
||||||
async (...[created]) => {
|
async (...[created]) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user