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). * 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 { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
@ -37,7 +38,7 @@ describe('BotStatsRepository', () => {
rootMongooseTestModule(installBotStatsFixtures), rootMongooseTestModule(installBotStatsFixtures),
MongooseModule.forFeature([BotStatsModel]), MongooseModule.forFeature([BotStatsModel]),
], ],
providers: [LoggerService, BotStatsRepository], providers: [LoggerService, BotStatsRepository, EventEmitter2],
}).compile(); }).compile();
botStatsRepository = module.get<BotStatsRepository>(BotStatsRepository); botStatsRepository = module.get<BotStatsRepository>(BotStatsRepository);
botStatsModel = module.get<Model<BotStats>>(getModelToken('BotStats')); botStatsModel = module.get<Model<BotStats>>(getModelToken('BotStats'));

View File

@ -7,6 +7,7 @@
*/ */
import { NotFoundException } from '@nestjs/common'; import { NotFoundException } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
@ -44,7 +45,12 @@ describe('ContextVarController', () => {
rootMongooseTestModule(installContextVarFixtures), rootMongooseTestModule(installContextVarFixtures),
MongooseModule.forFeature([ContextVarModel]), MongooseModule.forFeature([ContextVarModel]),
], ],
providers: [LoggerService, ContextVarService, ContextVarRepository], providers: [
LoggerService,
ContextVarService,
ContextVarRepository,
EventEmitter2,
],
}).compile(); }).compile();
contextVarController = contextVarController =
module.get<ContextVarController>(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). * 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 { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
@ -38,7 +39,7 @@ describe('BlockRepository', () => {
rootMongooseTestModule(installBlockFixtures), rootMongooseTestModule(installBlockFixtures),
MongooseModule.forFeature([BlockModel, CategoryModel, LabelModel]), MongooseModule.forFeature([BlockModel, CategoryModel, LabelModel]),
], ],
providers: [BlockRepository, CategoryRepository], providers: [BlockRepository, CategoryRepository, EventEmitter2],
}).compile(); }).compile();
blockRepository = module.get<BlockRepository>(BlockRepository); blockRepository = module.get<BlockRepository>(BlockRepository);
categoryRepository = module.get<CategoryRepository>(CategoryRepository); 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). * 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 { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
@ -52,6 +53,7 @@ describe('ContentTypeRepository', () => {
findOne: jest.fn(), findOne: jest.fn(),
}, },
}, },
EventEmitter2,
], ],
}).compile(); }).compile();
blockService = module.get<BlockService>(BlockService); 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). * 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 { MongooseModule, getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
@ -40,7 +41,7 @@ describe('ContentRepository', () => {
rootMongooseTestModule(installContentFixtures), rootMongooseTestModule(installContentFixtures),
MongooseModule.forFeature([ContentTypeModel, ContentModel]), MongooseModule.forFeature([ContentTypeModel, ContentModel]),
], ],
providers: [LoggerService, ContentRepository], providers: [LoggerService, ContentRepository, EventEmitter2],
}).compile(); }).compile();
contentRepository = module.get<ContentRepository>(ContentRepository); contentRepository = module.get<ContentRepository>(ContentRepository);
contentModel = module.get<Model<Content>>(getModelToken('Content')); contentModel = module.get<Model<Content>>(getModelToken('Content'));