mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat(api): add automatic DI to setting module
This commit is contained in:
parent
7a9face440
commit
a3908505ff
@ -6,9 +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 { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { I18nService } from '@/i18n/services/i18n.service';
|
||||
import {
|
||||
installSettingFixtures,
|
||||
@ -20,9 +17,7 @@ import {
|
||||
} from '@/utils/test/test';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { SettingRepository } from '../repositories/setting.repository';
|
||||
import { Setting, SettingModel } from '../schemas/setting.schema';
|
||||
import { SettingSeeder } from '../seeds/setting.seed';
|
||||
import { Setting } from '../schemas/setting.schema';
|
||||
import { SettingService } from '../services/setting.service';
|
||||
|
||||
import { SettingController } from './setting.controller';
|
||||
@ -33,29 +28,16 @@ describe('SettingController', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
autoInjectFrom: ['controllers'],
|
||||
controllers: [SettingController],
|
||||
imports: [
|
||||
rootMongooseTestModule(installSettingFixtures),
|
||||
MongooseModule.forFeature([SettingModel]),
|
||||
],
|
||||
imports: [rootMongooseTestModule(installSettingFixtures)],
|
||||
providers: [
|
||||
SettingService,
|
||||
SettingRepository,
|
||||
SettingSeeder,
|
||||
{
|
||||
provide: I18nService,
|
||||
useValue: {
|
||||
t: jest.fn().mockImplementation((t) => t),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
[settingController, settingService] = await getMocks([
|
||||
|
@ -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 { installSettingFixtures } from '@/utils/test/fixtures/setting';
|
||||
@ -16,7 +16,7 @@ import {
|
||||
} from '@/utils/test/test';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { Setting, SettingModel } from '../schemas/setting.schema';
|
||||
import { Setting } from '../schemas/setting.schema';
|
||||
import { SettingType } from '../schemas/types';
|
||||
|
||||
import { SettingRepository } from './setting.repository';
|
||||
@ -27,10 +27,8 @@ describe('SettingRepository', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installSettingFixtures),
|
||||
MongooseModule.forFeature([SettingModel]),
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installSettingFixtures)],
|
||||
providers: [SettingRepository],
|
||||
});
|
||||
[settingRepository, settingModel] = await getMocks([
|
||||
|
@ -6,9 +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 { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { I18nService } from '@/i18n/services/i18n.service';
|
||||
import {
|
||||
installSettingFixtures,
|
||||
@ -21,9 +18,8 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { SettingRepository } from '../repositories/setting.repository';
|
||||
import { Setting, SettingModel } from '../schemas/setting.schema';
|
||||
import { Setting } from '../schemas/setting.schema';
|
||||
import { SettingType } from '../schemas/types';
|
||||
import { SettingSeeder } from '../seeds/setting.seed';
|
||||
|
||||
import { SettingService } from './setting.service';
|
||||
|
||||
@ -39,28 +35,16 @@ describe('SettingService', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installSettingFixtures),
|
||||
MongooseModule.forFeature([SettingModel]),
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installSettingFixtures)],
|
||||
providers: [
|
||||
SettingService,
|
||||
SettingRepository,
|
||||
SettingSeeder,
|
||||
{
|
||||
provide: I18nService,
|
||||
useValue: {
|
||||
t: jest.fn().mockImplementation((t) => t),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
[settingService, settingRepository] = await getMocks([
|
||||
|
Loading…
Reference in New Issue
Block a user