-
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.
- Loading branch information
1 parent
cac224a
commit e8a0c56
Showing
10 changed files
with
1,955 additions
and
177 deletions.
There are no files selected for viewing
Binary file not shown.
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,25 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import App from "pages/App"; | ||
|
||
describe("App navigation", () => { | ||
it("should navigate to /home when the Home button is clicked", async () => { | ||
// MemoryRouter를 사용하여 초기 경로를 설정 | ||
render( | ||
<MemoryRouter initialEntries={["/"]}> | ||
<App /> | ||
</MemoryRouter>, | ||
); | ||
|
||
// Home 버튼을 찾고 클릭 이벤트를 발생시킴 | ||
const homeButton = screen.getByRole("link", { name: "logo" }); | ||
userEvent.click(homeButton); | ||
|
||
// 적절한 URL로 리디렉션이 되었는지 확인 | ||
// 주의: 실제 브라우저의 window.location은 변경되지 않으므로, 상태를 통해 판단해야 함 | ||
// MemoryRouter의 history 객체를 통해 URL 변경을 감지할 수 있음 | ||
expect(window.location.pathname).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
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,15 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import App from "./App"; | ||
|
||
describe("App Component", () => { | ||
it("renders correctly", () => { | ||
const { asFragment } = render( | ||
<MemoryRouter> | ||
<App /> | ||
</MemoryRouter>, | ||
); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
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,64 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`App Component renders correctly 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="App" | ||
> | ||
<div> | ||
<div | ||
class="stiky z-10 w-full h-12 text-white top-0" | ||
> | ||
<div | ||
class="flex w-full h-12 relative justify-between items-center my-0 mx-auto py-0 px-4" | ||
> | ||
<div | ||
class="h-full flex justify-center items-center" | ||
> | ||
<a | ||
href="/" | ||
> | ||
<img | ||
alt="logo" | ||
class="h-8 w-8" | ||
src="/images/rm-logo.png" | ||
/> | ||
</a> | ||
</div> | ||
<div | ||
class="flex justify-center items-center" | ||
> | ||
<a | ||
href="https://github.com/" | ||
> | ||
<img | ||
alt="github" | ||
class="h-8 w-8 mr-3" | ||
src="/images/github-logo.svg" | ||
/> | ||
</a> | ||
<img | ||
alt="dark" | ||
class="h-8 w-8 mr-3" | ||
src="/images/light-to-dark.svg" | ||
/> | ||
<button | ||
class="p-0 btn btn-transparent" | ||
type="button" | ||
> | ||
<img | ||
alt="mypage" | ||
class="h-8 w-8" | ||
src="/images/mypage.svg" | ||
/> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div> | ||
Homepage | ||
</div> | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; |
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.