-
Notifications
You must be signed in to change notification settings - Fork 2
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
9857fb9
commit 6dd70c8
Showing
12 changed files
with
145 additions
and
24 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
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,60 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import App from "./App"; | ||
|
||
describe("App", () => { | ||
it("renders correctly", () => { | ||
render(<App />); | ||
|
||
expect(screen.getByTestId("app-logo")).toBeInTheDocument(); | ||
expect(screen.getByText("Login")).toBeInTheDocument(); | ||
|
||
expect(localStorage.getItem("token")).toBeNull(); | ||
|
||
expect(screen.queryByTestId("note-app")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("renders correctly when logged in", async () => { | ||
render(<App />); | ||
|
||
const username = screen.getByTestId("username"); | ||
const password = screen.getByTestId("password"); | ||
const loginButton = screen.getByText("Login"); | ||
|
||
userEvent.type(username, "test"); | ||
userEvent.type(password, "pass"); | ||
userEvent.click(loginButton); | ||
|
||
const noteApp = await screen.findByTestId("note-app"); | ||
|
||
expect(noteApp).toBeInTheDocument(); | ||
|
||
expect(localStorage.getItem("token")).not.toBeNull(); | ||
}); | ||
|
||
it("renders correctly when logged out", async () => { | ||
render(<App />); | ||
|
||
const username = screen.getByTestId("username"); | ||
const password = screen.getByTestId("password"); | ||
const loginButton = screen.getByText("Login"); | ||
|
||
userEvent.type(username, "test"); | ||
userEvent.type(password, "pass"); | ||
userEvent.click(loginButton); | ||
|
||
const noteApp = await screen.findByTestId("note-app"); | ||
|
||
expect(noteApp).toBeInTheDocument(); | ||
|
||
const logoutButton = screen.getByText("Logout"); | ||
|
||
userEvent.click(logoutButton); | ||
|
||
expect(localStorage.getItem("token")).toBeNull(); | ||
|
||
expect(screen.queryByTestId("note-app")).not.toBeInTheDocument(); | ||
|
||
expect(screen.getByText("Login")).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
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,9 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import Header from './Header'; | ||
|
||
describe('Header', () => { | ||
it('renders correctly', () => { | ||
render(<Header />); | ||
expect(screen.getByTestId('app-logo')).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
6dd70c8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage for this commit
Coverage Report
6dd70c8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage for this commit
Coverage Report