Skip to content

Commit

Permalink
test: fix test suite errors
Browse files Browse the repository at this point in the history
  • Loading branch information
async3619 committed Jun 20, 2023
1 parent 1d64d52 commit ab6a19a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/thumbnail/thumbnail.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
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;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ThumbnailController],
providers: [
{ provide: ThumbnailService, useValue: {} },
{ provide: AttachmentService, useValue: {} },
],
}).compile();

controller = module.get<ThumbnailController>(ThumbnailController);
Expand Down
2 changes: 1 addition & 1 deletion src/thumbnail/thumbnail.controller.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
17 changes: 15 additions & 2 deletions src/thumbnail/thumbnail.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(ThumbnailService);
Expand Down

0 comments on commit ab6a19a

Please sign in to comment.