-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: (#205) 카테고리에 관련된 API 서버와 연동 wus폴더에 있던 파일들 밖으로 이동 * feat: (#205) 게시글 작성 페이지에서 카테고리 리스트를 불러와 옵션으로 변환하는 기능 구현 * refactor: (#205) 마감 시간을 구하는 유틸 함수 분리 * refactor: (#205) sua 폴더에 있던 post.ts MSW 코드를 밖의 post.ts 파일과 병합 * refactor: (#205) wus 폴더에 있던 유저 MSW 코드 밖으로 이동 * refactor: (#205) wus 폴더의 게시글 목록 MSW 코드를 밖으로 분리 및 파일명 변경 * refactor: (#205) api 폴더에 있던 wus 폴더 삭제 및 파일 이동 * refactor: (#205) 댓글을 제외한 나머지 api에 BASE_URL 코드 추가 * refactor: (#205) AuthContext에서 User 타입 변경 및 액세스 토큰이 있을 경우 isLogged:true로 수정 * fix: (#205) 게시글의 카테고리 리스트에 ?를 붙혀 없어도 에러가 나지 않게 수정 * feat: (#205) 게시글 서버에서 받는 타입 명세 선언 * refactor: (#205) 서버에서 받은 게시글 목록을 클라이언트에서 사용하는 게시글 목록 명세로 변환 * refactor: (#205) 게시글 명세인 startTime, endTime의 이름을 변경
- Loading branch information
1 parent
7ef315f
commit 626f753
Showing
40 changed files
with
395 additions
and
228 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Category } from '@type/category'; | ||
|
||
import { Option } from '@components/common/MultiSelect/types'; | ||
|
||
import { changeCategoryToOption } from '@utils/post/changeCategoryToOption'; | ||
|
||
describe('changeCategoryToOption 함수를 이용해서 카테고리 리스트를 셀렉트 컴포넌트에 사용되는 옵션 리스트로 변환한다.', () => { | ||
test('카테고리 리스트로 옵션 리스트를 만든다.', () => { | ||
const categoryList: Category[] = [ | ||
{ id: 1, isFavorite: false, name: '갤럭시' }, | ||
{ id: 2, isFavorite: true, name: '애플' }, | ||
]; | ||
|
||
const result: Option[] = changeCategoryToOption(categoryList); | ||
|
||
expect(result).toEqual([ | ||
{ | ||
id: 1, | ||
name: '갤럭시', | ||
}, | ||
{ | ||
id: 2, | ||
name: '애플', | ||
}, | ||
]); | ||
}); | ||
}); |
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,53 @@ | ||
import { getDeadlineTime } from '@utils/post/getDeadlineTime'; | ||
|
||
describe('getDeadlineTime를 이용하여 사용자에게 마감 시간을 알려준다.', () => { | ||
test('5분을 설정했을 때 5분으로 표시된다', () => { | ||
const result = getDeadlineTime({ | ||
day: 0, | ||
hour: 0, | ||
minute: 5, | ||
}); | ||
|
||
expect(result).toBe('5분 후에 마감됩니다.'); | ||
}); | ||
|
||
test('1시간 5분을 설정했을 때 1시간 5분으로 표시된다', () => { | ||
const result = getDeadlineTime({ | ||
day: 0, | ||
hour: 1, | ||
minute: 5, | ||
}); | ||
|
||
expect(result).toBe('1시간 5분 후에 마감됩니다.'); | ||
}); | ||
|
||
test('2일 23시간 59분을 설정했을 때 2일 23시간 59분으로 표시된다', () => { | ||
const result = getDeadlineTime({ | ||
day: 2, | ||
hour: 23, | ||
minute: 59, | ||
}); | ||
|
||
expect(result).toBe('2일 23시간 59분 후에 마감됩니다.'); | ||
}); | ||
|
||
test('0일 0시간 0분을 설정했을 때 "마감 시간을 선택해주세요"를 표시된다', () => { | ||
const result = getDeadlineTime({ | ||
day: 0, | ||
hour: 0, | ||
minute: 0, | ||
}); | ||
|
||
expect(result).toBe('마감 시간을 선택해주세요'); | ||
}); | ||
|
||
test('-1일 -1시간 -1분을 설정했을 때 "마감 시간을 다시 설정해주세요"를 표시된다', () => { | ||
const result = getDeadlineTime({ | ||
day: -1, | ||
hour: -1, | ||
minute: -1, | ||
}); | ||
|
||
expect(result).toBe('마감 시간을 다시 설정해주세요'); | ||
}); | ||
}); |
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,48 @@ | ||
import React, { ReactNode } from 'react'; | ||
|
||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { renderHook, waitFor } from '@testing-library/react'; | ||
|
||
import { useCategoryList } from '@hooks/query/category/useCategoryList'; | ||
|
||
import { transformCategoryListResponse } from '@api/categoryList'; | ||
|
||
import { MOCK_CATEGORY_LIST, MOCK_GUEST_CATEGORY_LIST } from '@mocks/mockData/categoryList'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const wrapper = ({ children }: { children: ReactNode }) => ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
); | ||
|
||
describe('useCategoryList 훅이 카테고리 목록을 불러오는지 확인한다.', () => { | ||
test('비회원 카테고리 목록을 불러온다.', async () => { | ||
const { result } = renderHook(() => useCategoryList(false), { | ||
wrapper, | ||
}); | ||
|
||
await waitFor(() => | ||
expect(result.current.data).toEqual(transformCategoryListResponse(MOCK_GUEST_CATEGORY_LIST)) | ||
); | ||
}); | ||
|
||
test('회원 카테고리 목록을 불러온다.', async () => { | ||
const { result } = renderHook(() => useCategoryList(true), { | ||
wrapper, | ||
}); | ||
|
||
await waitFor(() => | ||
expect(result.current.data).toEqual(transformCategoryListResponse(MOCK_CATEGORY_LIST)) | ||
); | ||
}); | ||
|
||
test('회원 카테고리 목록을 불러온다.', async () => { | ||
const { result } = renderHook(() => useCategoryList(true), { | ||
wrapper, | ||
}); | ||
|
||
await waitFor(() => | ||
expect(result.current.data).toEqual(transformCategoryListResponse(MOCK_CATEGORY_LIST)) | ||
); | ||
}); | ||
}); |
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
Oops, something went wrong.