diff --git a/src/thumbnail/thumbnail.controller.spec.ts b/src/thumbnail/thumbnail.controller.spec.ts index a1b01ef..03b5014 100644 --- a/src/thumbnail/thumbnail.controller.spec.ts +++ b/src/thumbnail/thumbnail.controller.spec.ts @@ -1,6 +1,8 @@ import { Test, TestingModule } from "@nestjs/testing"; import { ThumbnailController } from "@thumbnail/thumbnail.controller"; +import { ThumbnailService } from "@thumbnail/thumbnail.service"; +import { AttachmentService } from "@attachment/attachment.service"; describe("ThumbnailController", () => { let controller: ThumbnailController; @@ -8,6 +10,10 @@ describe("ThumbnailController", () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [ThumbnailController], + providers: [ + { provide: ThumbnailService, useValue: {} }, + { provide: AttachmentService, useValue: {} }, + ], }).compile(); controller = module.get(ThumbnailController); diff --git a/src/thumbnail/thumbnail.controller.ts b/src/thumbnail/thumbnail.controller.ts index fcdb226..e054a55 100644 --- a/src/thumbnail/thumbnail.controller.ts +++ b/src/thumbnail/thumbnail.controller.ts @@ -1,10 +1,10 @@ +import path from "path"; import type { Response } from "express"; import { Controller, Get, Inject, Param, Res } from "@nestjs/common"; import { ThumbnailService } from "@thumbnail/thumbnail.service"; import { AttachmentService } from "@attachment/attachment.service"; -import path from "path"; @Controller("thumbnails") export class ThumbnailController { diff --git a/src/thumbnail/thumbnail.service.spec.ts b/src/thumbnail/thumbnail.service.spec.ts index 576e9a5..4d4b714 100644 --- a/src/thumbnail/thumbnail.service.spec.ts +++ b/src/thumbnail/thumbnail.service.spec.ts @@ -1,12 +1,25 @@ +import { getRepositoryToken } from "@nestjs/typeorm"; import { Test, TestingModule } from "@nestjs/testing"; -import { ThumbnailService } from "./thumbnail.service"; + +import { CONFIG_DATA } from "@config/config.module"; +import { Thumbnail } from "@thumbnail/models/thumbnail.model"; +import { ThumbnailService } from "@thumbnail/thumbnail.service"; +import { StorageService } from "@storage/storage.service"; + +import { configMockFactory } from "../../test/config.mock"; +import { repositoryMockFactory } from "../../test/repository.mock"; describe("ThumbnailService", () => { let service: ThumbnailService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [ThumbnailService], + providers: [ + ThumbnailService, + { provide: CONFIG_DATA, useFactory: configMockFactory }, + { provide: getRepositoryToken(Thumbnail), useFactory: repositoryMockFactory }, + { provide: StorageService, useValue: {} }, + ], }).compile(); service = module.get(ThumbnailService);