-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: 디데이가 1일 남은경우에도 24시간 미만 남은경우 남은 dday로 반환하도록 변경 * refactor: areDatesEqual 함수를 dateFormatter 유틸 함수로 이동 * fix: 중복된 함수 제거 * test: 데이터 포메팅 유틸 함수 테스트코드 추가 * test: 테스트 시 이미지 모듈은 mock string 값이 반환되도록 모킹 * test: 룸 카드의 남은 기간 정보 UI 렌더링 테스트 추가 * fix: 진행중인 방의 D-Day 가 잘못 표기되는 문제 해결 * test: 테스트 명세 오타 수정 * test: 방 상세정보의 모집/리뷰 마감까지 남은 시간 렌더링 테스트 추가 * test: jest 환경에서 시간대를 한국 시간대를 사용하도록 변경 * feat: SEO 최적화를 위해 html에 메타태그 추가 --------- Co-authored-by: Lee sang Yeop <[email protected]>
- Loading branch information
1 parent
48256cd
commit 2390af5
Showing
11 changed files
with
619 additions
and
29 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
171 changes: 171 additions & 0 deletions
171
frontend/src/components/roomDetailPage/roomInfoCard/RoomInfoCard.test.tsx
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,171 @@ | ||
import "@testing-library/jest-dom"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { ThemeProvider } from "styled-components"; | ||
import RoomInfoCard from "@/components/roomDetailPage/roomInfoCard/RoomInfoCard"; | ||
import { RoomInfo } from "@/@types/roomInfo"; | ||
import { theme } from "@/styles/theme"; | ||
|
||
const mockBaseRoomInfo: RoomInfo = { | ||
id: 1, | ||
manager: "darr", | ||
currentParticipants: 5, | ||
roomStatus: "OPEN", | ||
participationStatus: "PARTICIPATED", | ||
memberRole: "BOTH", | ||
title: "테스트 제목", | ||
content: "테스트 본문", | ||
repositoryLink: "테스트 링크", | ||
thumbnailLink: "테스트 썸네일", | ||
matchingSize: 5, | ||
keywords: ["테스트"], | ||
limitedParticipants: 10, | ||
recruitmentDeadline: "2024-10-05T10:30:00+09:00", | ||
reviewDeadline: "2024-10-08T10:30:00+09:00", | ||
}; | ||
|
||
describe("RoomInfoCard 컴포넌트 테스트", () => { | ||
beforeAll(() => { | ||
const mockDate = new Date("2024-10-02T10:30:00+09:00"); | ||
const OriginalDate = Date; | ||
|
||
jest.spyOn(global, "Date").mockImplementation((value) => { | ||
return value ? new OriginalDate(value) : new OriginalDate(mockDate); | ||
}); | ||
}); | ||
|
||
it("'모집'중인 방에 2일 이상 남으면 '리뷰 마감까지 남은 일', '모집 마감까지 남은 일'이 보인다", async () => { | ||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockBaseRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent("D-3"); | ||
expect(reviewLeftDay).toHaveTextContent("D-6"); | ||
}); | ||
|
||
it("'모집'이 24시간 미만, '리뷰'가 24시간 이상 남은 경우 '모집 마감까지 남은 시간', '리뷰 마감까지 남은 일'이 보인다", async () => { | ||
const mockRoomInfo: RoomInfo = { | ||
...mockBaseRoomInfo, | ||
recruitmentDeadline: "2024-10-03T00:30:00+09:00", | ||
reviewDeadline: "2024-10-05T00:30:00+09:00", | ||
}; | ||
|
||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent("14시간 0분 전"); | ||
expect(reviewLeftDay).toHaveTextContent("D-2"); | ||
}); | ||
|
||
it("'모집'이 24시간 미만, '리뷰'가 24시간 미만인 경우 '모집 마감까지 남은 시간', '리뷰 마감까지 남은 시간'이 보인다", async () => { | ||
const mockRoomInfo: RoomInfo = { | ||
...mockBaseRoomInfo, | ||
recruitmentDeadline: "2024-10-02T12:30:00+09:00", | ||
reviewDeadline: "2024-10-03T00:30:00+09:00", | ||
}; | ||
|
||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent("2시간 0분 전"); | ||
expect(reviewLeftDay).toHaveTextContent("14시간 0분 전"); | ||
}); | ||
|
||
it("'모집'완료 후 '진행 중'으로 바뀌었을 때 '리뷰'가 24시간 이상인 경우 '리뷰 마감까지 남은 일'이 보인다", async () => { | ||
const mockRoomInfo: RoomInfo = { | ||
...mockBaseRoomInfo, | ||
recruitmentDeadline: "2024-10-01T12:30:00+09:00", | ||
reviewDeadline: "2024-10-04T00:30:00+09:00", | ||
}; | ||
|
||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent(""); | ||
expect(reviewLeftDay).toHaveTextContent("D-1"); | ||
}); | ||
|
||
it("'모집'완료 후 '진행 중'으로 바뀌었을 때 '리뷰'가 24시간 미만인 경우 '리뷰 마감까지 남은 시간'이 보인다", async () => { | ||
const mockRoomInfo: RoomInfo = { | ||
...mockBaseRoomInfo, | ||
recruitmentDeadline: "2024-10-01T12:30:00+09:00", | ||
reviewDeadline: "2024-10-03T00:30:00+09:00", | ||
}; | ||
|
||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent(""); | ||
expect(reviewLeftDay).toHaveTextContent("14시간 0분 전"); | ||
}); | ||
|
||
it("'종료됨' 상태인 방에서는 남은 기간이 보이지 않는다", async () => { | ||
const mockRoomInfo: RoomInfo = { | ||
...mockBaseRoomInfo, | ||
roomStatus: "CLOSE", | ||
recruitmentDeadline: "2024-10-01T12:30:00+09:00", | ||
reviewDeadline: "2024-10-03T00:30:00+09:00", | ||
}; | ||
|
||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent(""); | ||
expect(reviewLeftDay).toHaveTextContent(""); | ||
}); | ||
|
||
it("'실패' 상태인 방에서는 남은 기간이 보이지 않는다", async () => { | ||
const mockRoomInfo: RoomInfo = { | ||
...mockBaseRoomInfo, | ||
roomStatus: "FAIL", | ||
recruitmentDeadline: "2024-10-01T12:30:00+09:00", | ||
reviewDeadline: "2024-10-03T00:30:00+09:00", | ||
}; | ||
|
||
render( | ||
<ThemeProvider theme={theme}> | ||
<RoomInfoCard roomInfo={mockRoomInfo} /> | ||
</ThemeProvider>, | ||
); | ||
|
||
const recruitLeftDay = screen.getByTestId("recruitLeftTime"); | ||
const reviewLeftDay = screen.getByTestId("reviewLeftTime"); | ||
|
||
expect(recruitLeftDay).toHaveTextContent(""); | ||
expect(reviewLeftDay).toHaveTextContent(""); | ||
}); | ||
}); |
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.