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:
parent
3d6994ecda
commit
2d799e0886
@ -7,12 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { NotFoundException } from '@nestjs/common/exceptions';
|
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 { BlockService } from '@/chat/services/block.service';
|
||||||
|
import { I18nService } from '@/i18n/services/i18n.service';
|
||||||
import { FieldType } from '@/setting/schemas/types';
|
import { FieldType } from '@/setting/schemas/types';
|
||||||
import { NOT_FOUND_ID } from '@/utils/constants/mock';
|
import { NOT_FOUND_ID } from '@/utils/constants/mock';
|
||||||
import { getUpdateOneError } from '@/utils/test/errors/messages';
|
import { getUpdateOneError } from '@/utils/test/errors/messages';
|
||||||
@ -26,10 +23,7 @@ import {
|
|||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { ContentTypeCreateDto } from '../dto/contentType.dto';
|
import { ContentTypeCreateDto } from '../dto/contentType.dto';
|
||||||
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
import { ContentType } from '../schemas/content-type.schema';
|
||||||
import { ContentRepository } from '../repositories/content.repository';
|
|
||||||
import { ContentType, ContentTypeModel } from '../schemas/content-type.schema';
|
|
||||||
import { ContentModel } from '../schemas/content.schema';
|
|
||||||
import { ContentTypeService } from '../services/content-type.service';
|
import { ContentTypeService } from '../services/content-type.service';
|
||||||
import { ContentService } from '../services/content.service';
|
import { ContentService } from '../services/content.service';
|
||||||
|
|
||||||
@ -44,26 +38,14 @@ describe('ContentTypeController', () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
|
autoInjectFrom: ['controllers'],
|
||||||
controllers: [ContentTypeController],
|
controllers: [ContentTypeController],
|
||||||
imports: [
|
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||||
rootMongooseTestModule(installContentFixtures),
|
|
||||||
MongooseModule.forFeature([
|
|
||||||
ContentTypeModel,
|
|
||||||
ContentModel,
|
|
||||||
AttachmentModel,
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
ContentTypeRepository,
|
|
||||||
ContentRepository,
|
|
||||||
AttachmentRepository,
|
|
||||||
ContentTypeService,
|
|
||||||
ContentService,
|
|
||||||
AttachmentService,
|
|
||||||
{
|
{
|
||||||
provide: BlockService,
|
provide: I18nService,
|
||||||
useValue: {
|
useValue: {
|
||||||
findOne: jest.fn(),
|
t: jest.fn().mockImplementation((t) => t),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { NotFoundException } from '@nestjs/common/exceptions';
|
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 { NOT_FOUND_ID } from '@/utils/constants/mock';
|
||||||
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
||||||
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
|
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
|
||||||
@ -25,10 +25,8 @@ import {
|
|||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { ContentCreateDto } from '../dto/content.dto';
|
import { ContentCreateDto } from '../dto/content.dto';
|
||||||
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
import { ContentType } from '../schemas/content-type.schema';
|
||||||
import { ContentRepository } from '../repositories/content.repository';
|
import { Content } from '../schemas/content.schema';
|
||||||
import { ContentType, ContentTypeModel } from '../schemas/content-type.schema';
|
|
||||||
import { Content, ContentModel } from '../schemas/content.schema';
|
|
||||||
import { ContentTypeService } from '../services/content-type.service';
|
import { ContentTypeService } from '../services/content-type.service';
|
||||||
import { ContentService } from '../services/content.service';
|
import { ContentService } from '../services/content.service';
|
||||||
|
|
||||||
@ -45,16 +43,16 @@ describe('ContentController', () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
|
autoInjectFrom: ['controllers'],
|
||||||
controllers: [ContentController],
|
controllers: [ContentController],
|
||||||
imports: [
|
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||||
rootMongooseTestModule(installContentFixtures),
|
|
||||||
MongooseModule.forFeature([ContentTypeModel, ContentModel]),
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
ContentTypeService,
|
{
|
||||||
ContentService,
|
provide: I18nService,
|
||||||
ContentRepository,
|
useValue: {
|
||||||
ContentTypeRepository,
|
t: jest.fn().mockImplementation((t) => t),
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
[contentController, contentService, contentTypeService] = await getMocks([
|
[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).
|
* 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 {
|
import {
|
||||||
installMenuFixtures,
|
installMenuFixtures,
|
||||||
offerMenuFixture,
|
offerMenuFixture,
|
||||||
@ -21,8 +18,6 @@ import {
|
|||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
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 { MenuType } from '../schemas/types/menu';
|
||||||
import { MenuService } from '../services/menu.service';
|
import { MenuService } from '../services/menu.service';
|
||||||
import { verifyTree } from '../utilities/verifyTree';
|
import { verifyTree } from '../utilities/verifyTree';
|
||||||
@ -34,22 +29,8 @@ describe('MenuController', () => {
|
|||||||
let menuService: MenuService;
|
let menuService: MenuService;
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
autoInjectFrom: ['controllers'],
|
||||||
rootMongooseTestModule(installMenuFixtures),
|
imports: [rootMongooseTestModule(installMenuFixtures)],
|
||||||
MongooseModule.forFeature([MenuModel]),
|
|
||||||
],
|
|
||||||
providers: [
|
|
||||||
MenuRepository,
|
|
||||||
MenuService,
|
|
||||||
{
|
|
||||||
provide: CACHE_MANAGER,
|
|
||||||
useValue: {
|
|
||||||
del: jest.fn(),
|
|
||||||
get: jest.fn(),
|
|
||||||
set: jest.fn(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
controllers: [MenuController],
|
controllers: [MenuController],
|
||||||
});
|
});
|
||||||
[menuController, menuService] = await getMocks([
|
[menuController, menuService] = await getMocks([
|
||||||
|
@ -6,27 +6,22 @@
|
|||||||
* 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 { MongooseModule, getModelToken } from '@nestjs/mongoose';
|
import { getModelToken } from '@nestjs/mongoose';
|
||||||
import { Model } from 'mongoose';
|
import { Model } from 'mongoose';
|
||||||
|
|
||||||
import { BlockRepository } from '@/chat/repositories/block.repository';
|
|
||||||
import { BlockModel } from '@/chat/schemas/block.schema';
|
|
||||||
import { BlockService } from '@/chat/services/block.service';
|
import { BlockService } from '@/chat/services/block.service';
|
||||||
import {
|
import { ContentType } from '@/cms/schemas/content-type.schema';
|
||||||
ContentType,
|
import { I18nService } from '@/i18n/services/i18n.service';
|
||||||
ContentTypeModel,
|
|
||||||
} from '@/cms/schemas/content-type.schema';
|
|
||||||
import {
|
import {
|
||||||
closeInMongodConnection,
|
closeInMongodConnection,
|
||||||
rootMongooseTestModule,
|
rootMongooseTestModule,
|
||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { Content, ContentModel } from '../schemas/content.schema';
|
import { Content } from '../schemas/content.schema';
|
||||||
|
|
||||||
import { installContentFixtures } from './../../utils/test/fixtures/content';
|
import { installContentFixtures } from './../../utils/test/fixtures/content';
|
||||||
import { ContentTypeRepository } from './content-type.repository';
|
import { ContentTypeRepository } from './content-type.repository';
|
||||||
import { ContentRepository } from './content.repository';
|
|
||||||
|
|
||||||
describe('ContentTypeRepository', () => {
|
describe('ContentTypeRepository', () => {
|
||||||
let contentTypeRepository: ContentTypeRepository;
|
let contentTypeRepository: ContentTypeRepository;
|
||||||
@ -36,19 +31,14 @@ describe('ContentTypeRepository', () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
autoInjectFrom: ['providers'],
|
||||||
rootMongooseTestModule(installContentFixtures),
|
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||||
MongooseModule.forFeature([ContentTypeModel, ContentModel, BlockModel]),
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
ContentRepository,
|
|
||||||
ContentTypeRepository,
|
ContentTypeRepository,
|
||||||
BlockService,
|
|
||||||
BlockRepository,
|
|
||||||
{
|
{
|
||||||
provide: BlockService,
|
provide: I18nService,
|
||||||
useValue: {
|
useValue: {
|
||||||
findOne: jest.fn(),
|
t: jest.fn().mockImplementation((t) => t),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -6,13 +6,10 @@
|
|||||||
* 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 { MongooseModule, getModelToken } from '@nestjs/mongoose';
|
import { getModelToken } from '@nestjs/mongoose';
|
||||||
import { Model } from 'mongoose';
|
import { Model } from 'mongoose';
|
||||||
|
|
||||||
import {
|
import { ContentType } from '@/cms/schemas/content-type.schema';
|
||||||
ContentType,
|
|
||||||
ContentTypeModel,
|
|
||||||
} from '@/cms/schemas/content-type.schema';
|
|
||||||
import { contentTypeFixtures } from '@/utils/test/fixtures/contenttype';
|
import { contentTypeFixtures } from '@/utils/test/fixtures/contenttype';
|
||||||
import { getPageQuery } from '@/utils/test/pagination';
|
import { getPageQuery } from '@/utils/test/pagination';
|
||||||
import {
|
import {
|
||||||
@ -21,7 +18,7 @@ import {
|
|||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { Content, ContentModel } from '../schemas/content.schema';
|
import { Content } from '../schemas/content.schema';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
contentFixtures,
|
contentFixtures,
|
||||||
@ -36,10 +33,9 @@ describe('ContentRepository', () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
models: ['ContentTypeModel'],
|
||||||
rootMongooseTestModule(installContentFixtures),
|
autoInjectFrom: ['providers'],
|
||||||
MongooseModule.forFeature([ContentTypeModel, ContentModel]),
|
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||||
],
|
|
||||||
providers: [ContentRepository],
|
providers: [ContentRepository],
|
||||||
});
|
});
|
||||||
[contentRepository, contentModel, contentTypeModel] = await getMocks([
|
[contentRepository, contentModel, contentTypeModel] = await getMocks([
|
||||||
|
@ -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).
|
* 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 {
|
import {
|
||||||
installMenuFixtures,
|
installMenuFixtures,
|
||||||
rootMenuFixtures,
|
rootMenuFixtures,
|
||||||
@ -18,7 +16,6 @@ import {
|
|||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { MenuModel } from '../schemas/menu.schema';
|
|
||||||
import { MenuType } from '../schemas/types/menu';
|
import { MenuType } from '../schemas/types/menu';
|
||||||
|
|
||||||
import { MenuRepository } from './menu.repository';
|
import { MenuRepository } from './menu.repository';
|
||||||
@ -27,10 +24,8 @@ describe('MenuRepository', () => {
|
|||||||
let menuRepository: MenuRepository;
|
let menuRepository: MenuRepository;
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
autoInjectFrom: ['providers'],
|
||||||
rootMongooseTestModule(installMenuFixtures),
|
imports: [rootMongooseTestModule(installMenuFixtures)],
|
||||||
MongooseModule.forFeature([MenuModel]),
|
|
||||||
],
|
|
||||||
providers: [MenuRepository],
|
providers: [MenuRepository],
|
||||||
});
|
});
|
||||||
[menuRepository] = await getMocks([MenuRepository]);
|
[menuRepository] = await getMocks([MenuRepository]);
|
||||||
|
@ -6,12 +6,8 @@
|
|||||||
* 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 { 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 { BlockService } from '@/chat/services/block.service';
|
||||||
|
import { I18nService } from '@/i18n/services/i18n.service';
|
||||||
import { installContentFixtures } from '@/utils/test/fixtures/content';
|
import { installContentFixtures } from '@/utils/test/fixtures/content';
|
||||||
import {
|
import {
|
||||||
closeInMongodConnection,
|
closeInMongodConnection,
|
||||||
@ -20,9 +16,6 @@ import {
|
|||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
||||||
import { ContentRepository } from '../repositories/content.repository';
|
|
||||||
import { ContentTypeModel } from '../schemas/content-type.schema';
|
|
||||||
import { ContentModel } from '../schemas/content.schema';
|
|
||||||
|
|
||||||
import { ContentTypeService } from './content-type.service';
|
import { ContentTypeService } from './content-type.service';
|
||||||
import { ContentService } from './content.service';
|
import { ContentService } from './content.service';
|
||||||
@ -35,25 +28,14 @@ describe('ContentTypeService', () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
autoInjectFrom: ['providers'],
|
||||||
rootMongooseTestModule(installContentFixtures),
|
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||||
MongooseModule.forFeature([
|
|
||||||
ContentTypeModel,
|
|
||||||
ContentModel,
|
|
||||||
AttachmentModel,
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
ContentTypeRepository,
|
|
||||||
ContentRepository,
|
|
||||||
AttachmentRepository,
|
|
||||||
ContentTypeService,
|
ContentTypeService,
|
||||||
ContentService,
|
|
||||||
AttachmentService,
|
|
||||||
{
|
{
|
||||||
provide: BlockService,
|
provide: I18nService,
|
||||||
useValue: {
|
useValue: {
|
||||||
findOne: jest.fn(),
|
t: jest.fn().mockImplementation((t) => t),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -6,10 +6,9 @@
|
|||||||
* 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 { MongooseModule } from '@nestjs/mongoose';
|
|
||||||
|
|
||||||
import { OutgoingMessageFormat } from '@/chat/schemas/types/message';
|
import { OutgoingMessageFormat } from '@/chat/schemas/types/message';
|
||||||
import { ContentOptions } from '@/chat/schemas/types/options';
|
import { ContentOptions } from '@/chat/schemas/types/options';
|
||||||
|
import { I18nService } from '@/i18n/services/i18n.service';
|
||||||
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
|
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
|
||||||
import {
|
import {
|
||||||
contentFixtures,
|
contentFixtures,
|
||||||
@ -22,10 +21,8 @@ import {
|
|||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { ContentTypeRepository } from '../repositories/content-type.repository';
|
|
||||||
import { ContentRepository } from '../repositories/content.repository';
|
import { ContentRepository } from '../repositories/content.repository';
|
||||||
import { ContentTypeModel } from '../schemas/content-type.schema';
|
import { Content } from '../schemas/content.schema';
|
||||||
import { Content, ContentModel } from '../schemas/content.schema';
|
|
||||||
|
|
||||||
import { ContentTypeService } from './content-type.service';
|
import { ContentTypeService } from './content-type.service';
|
||||||
import { ContentService } from './content.service';
|
import { ContentService } from './content.service';
|
||||||
@ -37,15 +34,16 @@ describe('ContentService', () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
autoInjectFrom: ['providers'],
|
||||||
rootMongooseTestModule(installContentFixtures),
|
imports: [rootMongooseTestModule(installContentFixtures)],
|
||||||
MongooseModule.forFeature([ContentTypeModel, ContentModel]),
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
ContentTypeRepository,
|
|
||||||
ContentRepository,
|
|
||||||
ContentTypeService,
|
ContentTypeService,
|
||||||
ContentService,
|
{
|
||||||
|
provide: I18nService,
|
||||||
|
useValue: {
|
||||||
|
t: jest.fn().mockImplementation((t) => t),
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
[contentService, contentTypeService, contentRepository] = await getMocks([
|
[contentService, contentTypeService, contentRepository] = await getMocks([
|
||||||
|
@ -6,9 +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 { CACHE_MANAGER } from '@nestjs/cache-manager';
|
|
||||||
import { NotFoundException } from '@nestjs/common';
|
import { NotFoundException } from '@nestjs/common';
|
||||||
import { MongooseModule } from '@nestjs/mongoose';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
installMenuFixtures,
|
installMenuFixtures,
|
||||||
@ -21,7 +19,6 @@ import {
|
|||||||
import { buildTestingMocks } from '@/utils/test/utils';
|
import { buildTestingMocks } from '@/utils/test/utils';
|
||||||
|
|
||||||
import { MenuRepository } from '../repositories/menu.repository';
|
import { MenuRepository } from '../repositories/menu.repository';
|
||||||
import { MenuModel } from '../schemas/menu.schema';
|
|
||||||
import { MenuType } from '../schemas/types/menu';
|
import { MenuType } from '../schemas/types/menu';
|
||||||
import { verifyTree } from '../utilities/verifyTree';
|
import { verifyTree } from '../utilities/verifyTree';
|
||||||
|
|
||||||
@ -32,22 +29,9 @@ describe('MenuService', () => {
|
|||||||
let menuRepository: MenuRepository;
|
let menuRepository: MenuRepository;
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { getMocks } = await buildTestingMocks({
|
const { getMocks } = await buildTestingMocks({
|
||||||
imports: [
|
autoInjectFrom: ['providers'],
|
||||||
rootMongooseTestModule(installMenuFixtures),
|
imports: [rootMongooseTestModule(installMenuFixtures)],
|
||||||
MongooseModule.forFeature([MenuModel]),
|
providers: [MenuService],
|
||||||
],
|
|
||||||
providers: [
|
|
||||||
MenuRepository,
|
|
||||||
MenuService,
|
|
||||||
{
|
|
||||||
provide: CACHE_MANAGER,
|
|
||||||
useValue: {
|
|
||||||
del: jest.fn(),
|
|
||||||
get: jest.fn(),
|
|
||||||
set: jest.fn(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
[menuService, menuRepository] = await getMocks([
|
[menuService, menuRepository] = await getMocks([
|
||||||
MenuService,
|
MenuService,
|
||||||
|
Loading…
Reference in New Issue
Block a user