fix(api): unit tests

This commit is contained in:
yassinedorbozgithub 2024-10-05 12:16:12 +01:00
parent be1787ec48
commit daffdead62
5 changed files with 15 additions and 4 deletions

View File

@ -6,6 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Model } from 'mongoose';
@ -37,7 +38,7 @@ describe('BotStatsRepository', () => {
rootMongooseTestModule(installBotStatsFixtures),
MongooseModule.forFeature([BotStatsModel]),
],
providers: [LoggerService, BotStatsRepository],
providers: [LoggerService, BotStatsRepository, EventEmitter2],
}).compile();
botStatsRepository = module.get<BotStatsRepository>(BotStatsRepository);
botStatsModel = module.get<Model<BotStats>>(getModelToken('BotStats'));

View File

@ -7,6 +7,7 @@
*/
import { NotFoundException } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule } from '@nestjs/mongoose';
import { Test } from '@nestjs/testing';
@ -44,7 +45,12 @@ describe('ContextVarController', () => {
rootMongooseTestModule(installContextVarFixtures),
MongooseModule.forFeature([ContextVarModel]),
],
providers: [LoggerService, ContextVarService, ContextVarRepository],
providers: [
LoggerService,
ContextVarService,
ContextVarRepository,
EventEmitter2,
],
}).compile();
contextVarController =
module.get<ContextVarController>(ContextVarController);

View File

@ -6,6 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test } from '@nestjs/testing';
import { Model } from 'mongoose';
@ -38,7 +39,7 @@ describe('BlockRepository', () => {
rootMongooseTestModule(installBlockFixtures),
MongooseModule.forFeature([BlockModel, CategoryModel, LabelModel]),
],
providers: [BlockRepository, CategoryRepository],
providers: [BlockRepository, CategoryRepository, EventEmitter2],
}).compile();
blockRepository = module.get<BlockRepository>(BlockRepository);
categoryRepository = module.get<CategoryRepository>(CategoryRepository);

View File

@ -6,6 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Model } from 'mongoose';
@ -52,6 +53,7 @@ describe('ContentTypeRepository', () => {
findOne: jest.fn(),
},
},
EventEmitter2,
],
}).compile();
blockService = module.get<BlockService>(BlockService);

View File

@ -6,6 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Model } from 'mongoose';
@ -40,7 +41,7 @@ describe('ContentRepository', () => {
rootMongooseTestModule(installContentFixtures),
MongooseModule.forFeature([ContentTypeModel, ContentModel]),
],
providers: [LoggerService, ContentRepository],
providers: [LoggerService, ContentRepository, EventEmitter2],
}).compile();
contentRepository = module.get<ContentRepository>(ContentRepository);
contentModel = module.get<Model<Content>>(getModelToken('Content'));