-
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.
✨ Feat: ProjectPage studies, projects api 연동 (#51)
Component 및 Hook 수정 1. useStudiesQuery, useProjectsQuery 2. useHandlePageNumber 3. PaginationButton 버그 수정 - 기술 선택, purpose(project or study), 검색어 입력시 pageNumber가 초기화되지 않는 문제 오타 수정 - TPaginationData 타입명 오타 수정
- Loading branch information
Showing
34 changed files
with
770 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { matchers } from "@emotion/jest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { palette } from "styles/palette"; | ||
|
||
import PaginationButtons from "."; | ||
|
||
expect.extend(matchers); | ||
const mockHandleClickNextArrow = jest.fn(); | ||
const mockHandleClickPageNumber = jest.fn(); | ||
const mockHandleClickPrevArrow = jest.fn(); | ||
const mockHandleClickNextDblArrow = jest.fn(); | ||
const mockHandleClickPrevDblArrow = jest.fn(); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe("pagination button 기능 test", () => { | ||
it("prev, next, prevDbl, nextDbl 버튼 클릭 test", async () => { | ||
const user = userEvent.setup(); | ||
|
||
render( | ||
<PaginationButtons | ||
totalPages={16} | ||
currentPage={1} | ||
handleClickPageNumber={mockHandleClickPageNumber} | ||
handleClickNextArrow={mockHandleClickNextArrow} | ||
handleClickPrevArrow={mockHandleClickPrevArrow} | ||
handleClickPrevDblArrow={mockHandleClickPrevDblArrow} | ||
handleClickNextDblArrow={mockHandleClickNextDblArrow} | ||
/>, | ||
); | ||
|
||
const next = screen.getByTestId("next"); | ||
const dblNext = screen.getByTestId("dbl-next"); | ||
let prev = screen.queryByTestId("prev"); | ||
let dblPrev = screen.queryByTestId("dbl-prev"); | ||
|
||
expect(next).toBeInTheDocument(); | ||
expect(dblNext).toBeInTheDocument(); | ||
expect(prev).not.toBeInTheDocument(); | ||
expect(dblPrev).not.toBeInTheDocument(); | ||
await user.click(next); | ||
await user.click(dblNext); | ||
expect(mockHandleClickNextArrow).toHaveBeenCalled(); | ||
expect(mockHandleClickNextDblArrow).toHaveBeenCalled(); | ||
|
||
const pageButton = screen.getByRole("button", { name: "3" }); | ||
await user.click(pageButton); | ||
expect(mockHandleClickPageNumber).toHaveBeenCalled(); | ||
|
||
jest.clearAllMocks(); | ||
|
||
render( | ||
<PaginationButtons | ||
totalPages={16} | ||
currentPage={16} | ||
handleClickPageNumber={mockHandleClickPageNumber} | ||
handleClickNextArrow={mockHandleClickNextArrow} | ||
handleClickPrevArrow={mockHandleClickPrevArrow} | ||
handleClickPrevDblArrow={mockHandleClickPrevDblArrow} | ||
handleClickNextDblArrow={mockHandleClickNextDblArrow} | ||
/>, | ||
); | ||
|
||
prev = screen.getByTestId("prev"); | ||
dblPrev = screen.getByTestId("dbl-prev"); | ||
await user.click(prev); | ||
await user.click(dblPrev); | ||
expect(mockHandleClickPrevArrow).toHaveBeenCalled(); | ||
expect(mockHandleClickPrevDblArrow).toHaveBeenCalled(); | ||
}); | ||
it("totalPage에 0이 전달된 경우, 페이지는 1개가 생성된다.", () => { | ||
render( | ||
<PaginationButtons | ||
totalPages={0} | ||
currentPage={1} | ||
handleClickPageNumber={mockHandleClickPageNumber} | ||
handleClickNextArrow={mockHandleClickNextArrow} | ||
handleClickPrevArrow={mockHandleClickPrevArrow} | ||
handleClickPrevDblArrow={mockHandleClickPrevDblArrow} | ||
handleClickNextDblArrow={mockHandleClickNextDblArrow} | ||
/>, | ||
); | ||
|
||
const pageButton = screen.getByRole("button", { name: "1" }); | ||
expect(pageButton).toBeInTheDocument(); | ||
}); | ||
|
||
it("현재 페이지 번호를 표시하는 버튼의 색은 bgMainOrange이다.", () => { | ||
render( | ||
<PaginationButtons | ||
totalPages={10} | ||
currentPage={3} | ||
handleClickPageNumber={mockHandleClickPageNumber} | ||
handleClickNextArrow={mockHandleClickNextArrow} | ||
handleClickPrevArrow={mockHandleClickPrevArrow} | ||
handleClickPrevDblArrow={mockHandleClickPrevDblArrow} | ||
handleClickNextDblArrow={mockHandleClickNextDblArrow} | ||
/>, | ||
); | ||
|
||
const currentNumberBtn = screen.getByRole("button", { name: "3" }); | ||
expect(currentNumberBtn).toHaveStyleRule( | ||
"background-color", | ||
`${palette.bgMainOrange}`, | ||
); | ||
}); | ||
it("현재 페이지 번호가 아닌 버튼의 색은 transparent이다.", () => { | ||
render( | ||
<PaginationButtons | ||
totalPages={10} | ||
currentPage={3} | ||
handleClickPageNumber={mockHandleClickPageNumber} | ||
handleClickNextArrow={mockHandleClickNextArrow} | ||
handleClickPrevArrow={mockHandleClickPrevArrow} | ||
handleClickPrevDblArrow={mockHandleClickPrevDblArrow} | ||
handleClickNextDblArrow={mockHandleClickNextDblArrow} | ||
/>, | ||
); | ||
|
||
const currentNumberBtn = screen.getByRole("button", { name: "1" }); | ||
expect(currentNumberBtn).toHaveStyleRule("background-color", "transparent"); | ||
}); | ||
}); |
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 styled from "@emotion/styled"; | ||
|
||
const Wrapper = styled.div` | ||
position: relative; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const Spinner = styled.div` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
font-size: 10rem; | ||
`; | ||
|
||
const Loading = () => { | ||
return ( | ||
<Wrapper> | ||
<Spinner>Loading...</Spinner> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default Loading; |
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,16 @@ | ||
import styled from "@emotion/styled"; | ||
import { palette } from "styles/palette"; | ||
|
||
const EmptyBox = styled.div` | ||
width: 100%; | ||
height: 80vh; | ||
background-color: ${palette.bgSubOrange}; | ||
border-radius: 1rem; | ||
opacity: 0.7; | ||
`; | ||
|
||
const Loading = () => { | ||
return <EmptyBox />; | ||
}; | ||
|
||
export default Loading; |
Oops, something went wrong.