Skip to content

Commit

Permalink
Test: 테스트 코드 수정
Browse files Browse the repository at this point in the history
- 업로드 모듈에서 테스트 모듈 의존성 추가
- 토익 문제 모듈에서 테스트 모듈 의존성 추가

Related to #18
  • Loading branch information
Zamoca42 committed Feb 11, 2024
1 parent b1b28fc commit 432f6a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
5 changes: 1 addition & 4 deletions backend/src/toeic/toeic.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ describe('ToeicController', () => {
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ToeicController],
providers: [
ToeicService,
{ provide: ToeicService, useClass: MockToeicService },
],
providers: [{ provide: ToeicService, useClass: MockToeicService }],
}).compile();

toeicService = module.get<ToeicService>(ToeicService);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/toeic/toeic.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ToeicService } from './toeic.service';
import { ApiSwagger } from 'src/common/swagger/api.decorator';
import { ApiSwagger } from '../common/swagger/api.decorator';

@Controller('toeic')
export class ToeicController {
Expand Down
12 changes: 6 additions & 6 deletions backend/src/toeic/toeic.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ToeicService } from './toeic.service';
import { SupabaseService } from '../supabase/supabase.service';
import { PrismaService } from '../prisma/prisma.service';

class MockSupabaseService {}
class MockPrisma {}

describe('ToeicService', () => {
let service: ToeicService;
let supabaseService: SupabaseService;
let prisma: PrismaService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
ToeicService,
{ provide: SupabaseService, useClass: MockSupabaseService },
{ provide: PrismaService, useClass: MockPrisma },
],
}).compile();

service = module.get<ToeicService>(ToeicService);
supabaseService = module.get<SupabaseService>(SupabaseService);
prisma = module.get<PrismaService>(PrismaService);
});

it('should be defined', () => {
expect(service).toBeDefined();
expect(supabaseService).toBeDefined();
expect(prisma).toBeDefined();
});
});
8 changes: 7 additions & 1 deletion backend/src/upload/upload.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,34 @@ import { Test, TestingModule } from '@nestjs/testing';
import { UploadController } from './upload.controller';
import { UploadService } from './upload.service';
import { ToeicService } from '../toeic/toeic.service';
import { AuthService } from '../auth/auth.service';

class MockToeicService {}
class MockAuthService {}

describe('PdfUploaderController', () => {
describe('UploaderController', () => {
let controller: UploadController;
let toeicService: ToeicService;
let authService: AuthService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [UploadController],
providers: [
UploadService,
{ provide: ToeicService, useClass: MockToeicService },
{ provide: AuthService, useClass: MockAuthService },
],
}).compile();

toeicService = module.get<ToeicService>(ToeicService);
authService = module.get<AuthService>(AuthService);
controller = module.get<UploadController>(UploadController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
expect(authService).toBeDefined();
expect(toeicService).toBeDefined();
});
});

0 comments on commit 432f6a8

Please sign in to comment.