mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat(api): add automatic DI to CMS module
This commit is contained in:
@@ -7,12 +7,9 @@
|
||||
*/
|
||||
|
||||
import { NotFoundException } from '@nestjs/common/exceptions';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { AttachmentRepository } from '@/attachment/repositories/attachment.repository';
|
||||
import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
|
||||
import { AttachmentService } from '@/attachment/services/attachment.service';
|
||||
import { BlockService } from '@/chat/services/block.service';
|
||||
import { I18nService } from '@/i18n/services/i18n.service';
|
||||
import { FieldType } from '@/setting/schemas/types';
|
||||
import { NOT_FOUND_ID } from '@/utils/constants/mock';
|
||||
import { getUpdateOneError } from '@/utils/test/errors/messages';
|
||||
@@ -26,10 +23,7 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { ContentTypeCreateDto } from '../dto/contentType.dto';
|
||||
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
||||
import { ContentRepository } from '../repositories/content.repository';
|
||||
import { ContentType, ContentTypeModel } from '../schemas/content-type.schema';
|
||||
import { ContentModel } from '../schemas/content.schema';
|
||||
import { ContentType } from '../schemas/content-type.schema';
|
||||
import { ContentTypeService } from '../services/content-type.service';
|
||||
import { ContentService } from '../services/content.service';
|
||||
|
||||
@@ -44,26 +38,14 @@ describe('ContentTypeController', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
autoInjectFrom: ['controllers'],
|
||||
controllers: [ContentTypeController],
|
||||
imports: [
|
||||
rootMongooseTestModule(installContentFixtures),
|
||||
MongooseModule.forFeature([
|
||||
ContentTypeModel,
|
||||
ContentModel,
|
||||
AttachmentModel,
|
||||
]),
|
||||
],
|
||||
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||
providers: [
|
||||
ContentTypeRepository,
|
||||
ContentRepository,
|
||||
AttachmentRepository,
|
||||
ContentTypeService,
|
||||
ContentService,
|
||||
AttachmentService,
|
||||
{
|
||||
provide: BlockService,
|
||||
provide: I18nService,
|
||||
useValue: {
|
||||
findOne: jest.fn(),
|
||||
t: jest.fn().mockImplementation((t) => t),
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import { NotFoundException } from '@nestjs/common/exceptions';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { I18nService } from '@/i18n/services/i18n.service';
|
||||
import { NOT_FOUND_ID } from '@/utils/constants/mock';
|
||||
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
||||
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
|
||||
@@ -25,10 +25,8 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { ContentCreateDto } from '../dto/content.dto';
|
||||
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
||||
import { ContentRepository } from '../repositories/content.repository';
|
||||
import { ContentType, ContentTypeModel } from '../schemas/content-type.schema';
|
||||
import { Content, ContentModel } from '../schemas/content.schema';
|
||||
import { ContentType } from '../schemas/content-type.schema';
|
||||
import { Content } from '../schemas/content.schema';
|
||||
import { ContentTypeService } from '../services/content-type.service';
|
||||
import { ContentService } from '../services/content.service';
|
||||
|
||||
@@ -45,16 +43,16 @@ describe('ContentController', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
autoInjectFrom: ['controllers'],
|
||||
controllers: [ContentController],
|
||||
imports: [
|
||||
rootMongooseTestModule(installContentFixtures),
|
||||
MongooseModule.forFeature([ContentTypeModel, ContentModel]),
|
||||
],
|
||||
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||
providers: [
|
||||
ContentTypeService,
|
||||
ContentService,
|
||||
ContentRepository,
|
||||
ContentTypeRepository,
|
||||
{
|
||||
provide: I18nService,
|
||||
useValue: {
|
||||
t: jest.fn().mockImplementation((t) => t),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
[contentController, contentService, contentTypeService] = 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 {
|
||||
installMenuFixtures,
|
||||
offerMenuFixture,
|
||||
@@ -21,8 +18,6 @@ import {
|
||||
} from '@/utils/test/test';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { MenuRepository } from '../repositories/menu.repository';
|
||||
import { MenuModel } from '../schemas/menu.schema';
|
||||
import { MenuType } from '../schemas/types/menu';
|
||||
import { MenuService } from '../services/menu.service';
|
||||
import { verifyTree } from '../utilities/verifyTree';
|
||||
@@ -34,22 +29,8 @@ describe('MenuController', () => {
|
||||
let menuService: MenuService;
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installMenuFixtures),
|
||||
MongooseModule.forFeature([MenuModel]),
|
||||
],
|
||||
providers: [
|
||||
MenuRepository,
|
||||
MenuService,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
autoInjectFrom: ['controllers'],
|
||||
imports: [rootMongooseTestModule(installMenuFixtures)],
|
||||
controllers: [MenuController],
|
||||
});
|
||||
[menuController, menuService] = await getMocks([
|
||||
|
||||
Reference in New Issue
Block a user