Skip to content

Commit

Permalink
test: 테스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Conut-1 committed Nov 13, 2024
1 parent 9dcfcc4 commit e7ff32f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions nestjs-BE/server/src/boards/boards.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { HttpStatus, NotFoundException } from '@nestjs/common';
import { UpdateWriteOpResult } from 'mongoose';
import { BoardsController } from './boards.controller';
import { BoardsService } from './boards.service';
import { CreateBoardDto } from './dto/create-board.dto';
Expand Down Expand Up @@ -86,9 +85,9 @@ describe('BoardsController', () => {
const bodyMock = { boardId: 'board uuid' };

it('success', async () => {
jest.spyOn(boardsService, 'deleteBoard').mockResolvedValue({
(boardsService.deleteBoard as jest.Mock).mockResolvedValue({
matchedCount: 1,
} as UpdateWriteOpResult);
});

const response = controller.deleteBoard(bodyMock);

Expand All @@ -99,9 +98,9 @@ describe('BoardsController', () => {
});

it('fail', async () => {
jest.spyOn(boardsService, 'deleteBoard').mockResolvedValue({
matchedCount: 0,
} as UpdateWriteOpResult);
(boardsService.deleteBoard as jest.Mock).mockRejectedValue(
new NotFoundException(),
);

const response = controller.deleteBoard(bodyMock);

Expand All @@ -113,9 +112,9 @@ describe('BoardsController', () => {
const bodyMock = { boardId: 'board uuid' };

it('success', async () => {
jest.spyOn(boardsService, 'restoreBoard').mockResolvedValue({
(boardsService.restoreBoard as jest.Mock).mockResolvedValue({
matchedCount: 1,
} as UpdateWriteOpResult);
});

const response = controller.restoreBoard(bodyMock);

Expand All @@ -126,9 +125,9 @@ describe('BoardsController', () => {
});

it('fail', async () => {
jest.spyOn(boardsService, 'restoreBoard').mockResolvedValue({
matchedCount: 0,
} as UpdateWriteOpResult);
(boardsService.restoreBoard as jest.Mock).mockRejectedValue(
new NotFoundException(),
);

const response = controller.restoreBoard(bodyMock);

Expand Down

0 comments on commit e7ff32f

Please sign in to comment.