forked from jupyterhub/binderhub
-
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.
Add router test for homepage and about page
Removes the router context from App into new index.jsx so we can test the app component and control which route is active in tests. index.jsx is the new entry point for the app.
- Loading branch information
1 parent
85113b0
commit 28dc23c
Showing
6 changed files
with
72 additions
and
43 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,27 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
import { App } from "./App"; | ||
import { MemoryRouter } from "react-router"; | ||
|
||
test("render Homepage", () => { | ||
render( | ||
<MemoryRouter> | ||
<App /> | ||
</MemoryRouter>, | ||
); | ||
expect( | ||
screen.queryByText( | ||
/Turn a Git repo into a collection of interactive notebooks/, | ||
), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
test("render About page", () => { | ||
render( | ||
<MemoryRouter initialEntries={["/about"]}> | ||
<App /> | ||
</MemoryRouter>, | ||
); | ||
expect(screen.queryByText(/This is the about message/)).toBeInTheDocument(); | ||
expect(screen.queryByText(/v123.456/)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createRoot } from "react-dom/client"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { App } from "./App"; | ||
|
||
const root = createRoot(document.getElementById("root")); | ||
root.render( | ||
<BrowserRouter> | ||
<App /> | ||
</BrowserRouter>, | ||
); |
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