Skip to content

Commit

Permalink
fix : no test aha
Browse files Browse the repository at this point in the history
  • Loading branch information
AkekoChan committed Jan 12, 2024
1 parent 10af620 commit c58c114
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/__tests__/Login.test.jsx
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();
// });
// });

0 comments on commit c58c114

Please sign in to comment.