Skip to content

Commit

Permalink
[GWL-166] Workouts API에 icon 이미지 컬럼 추가, Swagger 수정 (#179)
Browse files Browse the repository at this point in the history
* refactor: workouts entity에 icon string 컬럼 추가

* chore: swagger example 수정

* test: 데이터 변경에 따른 목데이터 수정
  • Loading branch information
wonholim authored Nov 29, 2023
1 parent 5a27cef commit bb8eae7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
21 changes: 17 additions & 4 deletions BackEnd/src/workouts/dto/workout-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ export const WorkoutResDtoSwagger = () => {
example: {
code: null,
errorMessage: null,
data: {
id: 1,
name: '달리기',
},
data: [
{
id: 1,
name: '달리기',
icon: 'figure.outdoor.a',
},
{
id: 2,
name: '수영',
icon: 'figure.outdoor.b',
},
{
id: 3,
name: '사이클',
icon: 'figure.outdoor.c',
},
]
},
};
};
8 changes: 8 additions & 0 deletions BackEnd/src/workouts/entities/workout.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export class Workout {
@IsString()
name: string;

@ApiProperty({
example: '운동 종류의 아이콘 경로 문자열',
description: 'figure.outdoor.workout',
})
@Column()
@IsString()
icon: string;

@OneToMany(() => Record, (record) => record.workout)
records: Record[];
}
12 changes: 6 additions & 6 deletions BackEnd/src/workouts/workouts.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe('WorkoutsService', () => {

beforeEach(async () => {
const mockWorkouts: Workout[] = [
{ id: 1, name: '달리기' } as Workout,
{ id: 2, name: '수영' } as Workout,
{ id: 3, name: '사이클' } as Workout,
{ id: 1, name: '달리기', icon: 'a' } as Workout,
{ id: 2, name: '수영', icon: 'b' } as Workout,
{ id: 3, name: '사이클', icon: 'c' } as Workout,
];

mockRepository = {
Expand All @@ -34,9 +34,9 @@ describe('WorkoutsService', () => {

it('서비스의 findAllworkouts는 목 데이터를 동일하게 리턴해야한다.', async () => {
expect(await service.findAllWorkouts()).toEqual([
{ id: 1, name: '달리기' } as Workout,
{ id: 2, name: '수영' } as Workout,
{ id: 3, name: '사이클' } as Workout,
{ id: 1, name: '달리기', icon: 'a' } as Workout,
{ id: 2, name: '수영', icon: 'b' } as Workout,
{ id: 3, name: '사이클', icon: 'c' } as Workout,
]);
expect(mockRepository.find).toHaveBeenCalled();
});
Expand Down

0 comments on commit bb8eae7

Please sign in to comment.