feat(api): add automatic DI to analytics module

This commit is contained in:
yassinedorbozgithub 2025-06-16 07:14:07 +01:00
parent 4d16e330d7
commit e7ae9a82d9
3 changed files with 11 additions and 29 deletions

View File

@ -6,8 +6,6 @@
* 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 { MongooseModule } from '@nestjs/mongoose';
import {
botstatsFixtures,
installBotStatsFixtures,
@ -18,9 +16,7 @@ import {
} from '@/utils/test/test';
import { buildTestingMocks } from '@/utils/test/utils';
import { BotStatsRepository } from '../repositories/bot-stats.repository';
import { BotStatsModel, BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsService } from '../services/bot-stats.service';
import { BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsController } from './bot-stats.controller';
@ -29,12 +25,9 @@ describe('BotStatsController', () => {
beforeAll(async () => {
const { getMocks } = await buildTestingMocks({
autoInjectFrom: ['controllers'],
controllers: [BotStatsController],
imports: [
rootMongooseTestModule(installBotStatsFixtures),
MongooseModule.forFeature([BotStatsModel]),
],
providers: [BotStatsService, BotStatsRepository],
imports: [rootMongooseTestModule(installBotStatsFixtures)],
});
[botStatsController] = await getMocks([BotStatsController]);
});

View File

@ -6,7 +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 { getModelToken, MongooseModule } from '@nestjs/mongoose';
import { getModelToken } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import {
@ -19,11 +19,7 @@ import {
} from '@/utils/test/test';
import { buildTestingMocks } from '@/utils/test/utils';
import {
BotStats,
BotStatsModel,
BotStatsType,
} from '../schemas/bot-stats.schema';
import { BotStats, BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsRepository } from './bot-stats.repository';
@ -33,10 +29,8 @@ describe('BotStatsRepository', () => {
beforeAll(async () => {
const { getMocks } = await buildTestingMocks({
imports: [
rootMongooseTestModule(installBotStatsFixtures),
MongooseModule.forFeature([BotStatsModel]),
],
autoInjectFrom: ['providers'],
imports: [rootMongooseTestModule(installBotStatsFixtures)],
providers: [BotStatsRepository],
});
[botStatsRepository, botStatsModel] = await getMocks([

View File

@ -6,8 +6,6 @@
* 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 { MongooseModule } from '@nestjs/mongoose';
import {
botstatsFixtures,
installBotStatsFixtures,
@ -18,8 +16,7 @@ import {
} from '@/utils/test/test';
import { buildTestingMocks } from '@/utils/test/utils';
import { BotStatsRepository } from '../repositories/bot-stats.repository';
import { BotStatsModel, BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsService } from './bot-stats.service';
@ -28,11 +25,9 @@ describe('BotStatsService', () => {
beforeAll(async () => {
const { getMocks } = await buildTestingMocks({
imports: [
rootMongooseTestModule(installBotStatsFixtures),
MongooseModule.forFeature([BotStatsModel]),
],
providers: [BotStatsService, BotStatsRepository],
autoInjectFrom: ['providers'],
imports: [rootMongooseTestModule(installBotStatsFixtures)],
providers: [BotStatsService],
});
[botStatsService] = await getMocks([BotStatsService]);
});