-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add testcode for MonthCalendar Container
- Loading branch information
Showing
4 changed files
with
34 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { MONTH_BODY, MONTH_HEADER } from "@/constants/testId"; | ||
import MonthCalendar from "@/container/MonthCalendar"; | ||
import "@testing-library/jest-dom"; | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
jest.mock("next/navigation", () => ({ | ||
useRouter: () => ({ | ||
push: jest.fn(), | ||
}), | ||
})); | ||
|
||
describe("Container - MonthCalendar", () => { | ||
it("연월 정보가 없는 경우에도 MonthCalendar는 정상적으로 렌더링된다", () => { | ||
render(<MonthCalendar searchParams={{}} />); | ||
const monthBody = screen.getByTestId(MONTH_BODY); | ||
const monthHeader = screen.getByTestId(MONTH_HEADER); | ||
expect(monthBody).toBeInTheDocument(); | ||
expect(monthHeader).toBeInTheDocument(); | ||
}); | ||
|
||
it("윤년의 정보가 주어져도 2월 29일은 정상적으로 렌더링 된다", () => { | ||
render(<MonthCalendar searchParams={{ year: "2024", month: "2" }} />); | ||
const monthBody = screen.getByTestId(MONTH_BODY); | ||
const monthHeader = screen.getByTestId(MONTH_HEADER); | ||
expect(monthBody).toBeInTheDocument(); | ||
expect(monthHeader).toBeInTheDocument(); | ||
const feb29 = screen.getByText("2/29"); | ||
expect(feb29).toBeInTheDocument(); | ||
}); | ||
}); |
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,2 +1,3 @@ | ||
export const ROOT_ID = "root-layout"; | ||
export const MONTH_BODY = "month-body"; | ||
export const MONTH_HEADER = "month-header"; |