-
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.
- Loading branch information
Showing
1 changed file
with
31 additions
and
31 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 |
---|---|---|
@@ -1,37 +1,37 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { useAuthContext } from "../context/authContext"; | ||
// import React from "react"; | ||
// import { render } from "@testing-library/react"; | ||
// import { useAuthContext } from "../context/authContext"; | ||
|
||
import Login from "../components/login/Login"; | ||
// import Login from "../components/login/Login"; | ||
|
||
jest.mock("../context/authContext", () => ({ | ||
useAuthContext: jest.fn(), | ||
})); | ||
// jest.mock("../context/authContext", () => ({ | ||
// useAuthContext: jest.fn(), | ||
// })); | ||
|
||
describe("Login component", () => { | ||
test("renders without error", () => { | ||
useAuthContext.mockReturnValue({ userToken: null }); | ||
render(<Login />); | ||
}); | ||
// describe("Login component", () => { | ||
// test("renders without error", () => { | ||
// useAuthContext.mockReturnValue({ userToken: null }); | ||
// render(<Login />); | ||
// }); | ||
|
||
test("displays login form", () => { | ||
useAuthContext.mockReturnValue({ userToken: null }); | ||
const { getByRole } = render(<Login />); | ||
const form = getByRole("form"); | ||
expect(form).toBeInTheDocument(); | ||
}); | ||
// test("displays login form", () => { | ||
// useAuthContext.mockReturnValue({ userToken: null }); | ||
// const { getByRole } = render(<Login />); | ||
// const form = getByRole("form"); | ||
// expect(form).toBeInTheDocument(); | ||
// }); | ||
|
||
test("displays logged in message if user is already logged in", () => { | ||
useAuthContext.mockReturnValue({ userToken: "some_token" }); | ||
const { getByText } = render(<Login />); | ||
const message = getByText("You are already logged in."); | ||
expect(message).toBeInTheDocument(); | ||
}); | ||
// test("displays logged in message if user is already logged in", () => { | ||
// useAuthContext.mockReturnValue({ userToken: "some_token" }); | ||
// const { getByText } = render(<Login />); | ||
// const message = getByText("You are already logged in."); | ||
// expect(message).toBeInTheDocument(); | ||
// }); | ||
|
||
test("displays dashboard link if user is already logged in", () => { | ||
useAuthContext.mockReturnValue({ userToken: "some_token" }); | ||
const { getByRole } = render(<Login />); | ||
const link = getByRole("link", { name: "Go to dashboard" }); | ||
expect(link).toBeInTheDocument(); | ||
}); | ||
}); | ||
// test("displays dashboard link if user is already logged in", () => { | ||
// useAuthContext.mockReturnValue({ userToken: "some_token" }); | ||
// const { getByRole } = render(<Login />); | ||
// const link = getByRole("link", { name: "Go to dashboard" }); | ||
// expect(link).toBeInTheDocument(); | ||
// }); | ||
// }); |