mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): enhance unit tests
This commit is contained in:
parent
daa2bb61d9
commit
0e1d57dba1
@ -116,16 +116,17 @@ describe('NlpEntityRepository', () => {
|
||||
|
||||
describe('The deleteCascadeOne function', () => {
|
||||
it('should delete a nlp entity', async () => {
|
||||
nlpValueRepository.eventEmitter.on(
|
||||
'hook:nlpEntity:preDelete',
|
||||
async (...args) => {
|
||||
await nlpService.handleEntityDelete(args[0], args[1]);
|
||||
},
|
||||
);
|
||||
const intentNlpEntity = await nlpEntityRepository.findOne({
|
||||
name: 'intent',
|
||||
});
|
||||
const result = await nlpEntityRepository.deleteOne(intentNlpEntity!.id);
|
||||
|
||||
await nlpService.handleEntityDelete(
|
||||
{},
|
||||
{ _id: intentNlpEntity!.id, builtin: { $ne: true } },
|
||||
);
|
||||
|
||||
expect(result.deletedCount).toEqual(1);
|
||||
|
||||
const intentNlpValues = await nlpValueRepository.find({
|
||||
|
@ -75,8 +75,6 @@ describe('NlpValueRepository', () => {
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
},
|
||||
},
|
||||
@ -169,12 +167,13 @@ describe('NlpValueRepository', () => {
|
||||
|
||||
describe('The deleteCascadeOne function', () => {
|
||||
it('should delete a nlp Value', async () => {
|
||||
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
|
||||
|
||||
await nlpService.handleValueDelete(
|
||||
{},
|
||||
{ _id: nlpValues[1].id, builtin: { $ne: true } },
|
||||
nlpValueRepository.eventEmitter.on(
|
||||
'hook:nlpValue:preDelete',
|
||||
async (...args) => {
|
||||
await nlpService.handleValueDelete(args[0], args[1]);
|
||||
},
|
||||
);
|
||||
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
|
||||
|
||||
expect(result.deletedCount).toEqual(1);
|
||||
const sampleEntities = await nlpSampleEntityRepository.find({
|
||||
|
Loading…
Reference in New Issue
Block a user