-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GWL-212] Workouts API 테스트 코드 작성 및 리팩토링 (#248)
* feat: workouts에 3000, 3100 번 커스텀 에러 생성 * chore: response dto에서 Schema Swagger 삭제 및 수정 * test: workouts의 테스트 코드 작성, 만약, 오류가 발생했을때 에러를 잘 처리하는지의 테스트 코드를 작성했습니다. * chore: format 적용 * chore: 절대 경로에서 상대 경로로 변경 * chore: 절대 경로에서 상대 경로로 변경 * chore: 절대 경로에서 상대 경로로 변경 * test: workouts controller 테스트 코드 작성 * refactor: workout entity에 @isnotempty 문장 추가 * test: findOne 목 추가 * test: entity 테스트 코드 작성 * test: response dto 테스트 코드 작성
Showing
39 changed files
with
240 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { SuccessResDto } from 'src/common/dto/SuccessRes.dto'; | ||
import { SuccessResDto } from '../../common/dto/SuccessRes.dto'; | ||
|
||
export class DeletePostResponseDto extends SuccessResDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { BasePaginationDto } from 'src/common/dto/base-pagination.dto'; | ||
import {BasePaginationDto} from "../../common/dto/base-pagination.dto"; | ||
|
||
export class PaginatePostDto extends BasePaginationDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { BasePaginationDto } from 'src/common/dto/base-pagination.dto'; | ||
import { BasePaginationDto } from '../../common/dto/base-pagination.dto'; | ||
|
||
export class PaginateProfilePostDto extends BasePaginationDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { WorkoutResDto } from './workout-response.dto'; | ||
import { Workout } from '../entities/workout.entity'; | ||
|
||
describe('WorkoutResDto', () => { | ||
it('WorkoutResDto는 배열을 리턴하며 내부에는 id, name, icon이 존재한다.', () => { | ||
const workout1 = new Workout(); | ||
workout1.id = 1; | ||
workout1.name = '달리기'; | ||
workout1.icon = 'running.svg'; | ||
|
||
const workout2 = new Workout(); | ||
workout2.id = 2; | ||
workout2.name = '수영'; | ||
workout2.icon = 'swimming.svg'; | ||
|
||
const dto = new WorkoutResDto(); | ||
dto.data = [workout1, workout2]; | ||
|
||
expect(dto.data).toBeInstanceOf(Array); | ||
expect(dto.data[0]).toBeInstanceOf(Workout); | ||
expect(dto.data[0].name).toBe('달리기'); | ||
expect(dto.data[1].name).toBe('수영'); | ||
expect(dto.data[1].icon).toBe('swimming.svg'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Workout } from './workout.entity'; | ||
import { validate } from 'class-validator'; | ||
|
||
describe('Workout Entity', () => { | ||
it('Workout에서 id, name, icon이 엔티티에 정의한대로 올바르면, 에러가 발생하지 않는다.', async () => { | ||
const workout = new Workout(); | ||
workout.id = 1; | ||
workout.name = '달리기'; | ||
workout.icon = 'running'; | ||
|
||
const errors = await validate(workout); | ||
expect(errors).toHaveLength(0); | ||
}); | ||
|
||
it('Workout에서 name이 공백이면, 에러가 발생한다.', async () => { | ||
const workout = new Workout(); | ||
workout.id = 1; | ||
workout.name = ''; | ||
workout.icon = 'running'; | ||
|
||
const errors = await validate(workout); | ||
expect(errors).toHaveLength(1); | ||
}); | ||
|
||
it('Workout에서 icon이 공백이면, 에러가 발생한다.', async () => { | ||
const workout = new Workout(); | ||
workout.id = 1; | ||
workout.name = '달리기'; | ||
workout.icon = ''; | ||
|
||
const errors = await validate(workout); | ||
expect(errors).toHaveLength(1); | ||
}); | ||
|
||
}); |
Oops, something went wrong.