fix(api): enhance unit tests

This commit is contained in:
yassinedorbozgithub 2025-06-13 15:55:10 +01:00
parent daa2bb61d9
commit 0e1d57dba1
2 changed files with 12 additions and 12 deletions

View File

@ -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({

View File

@ -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({