@@ -4,9 +4,9 @@ jest.mock("../Contexts/VehicleContext");
|
||||
|
||||
import { render, screen, cleanup, waitForElementToBeRemoved } from "@testing-library/react";
|
||||
import { setToken } from "../Contexts/UserContext";
|
||||
import { TEST_AUTH_OBJECT } from "../../utils/testing"
|
||||
import App from ".";
|
||||
|
||||
const TEST_TOKEN = { idToken: { jwtToken: "TEST" } };
|
||||
const LOADING_STATUS = "Loading...";
|
||||
|
||||
const renderRoute = async (route) => {
|
||||
@@ -37,6 +37,12 @@ describe("App", () => {
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Route /package-upload unauthenticated", async () => {
|
||||
const container = await renderRoute("/package-upload");
|
||||
expect(container.querySelector("span.MuiButton-label").innerHTML).toEqual("Sign In");
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Route /vehicle-add unauthenticated", async () => {
|
||||
const container = await renderRoute("/vehicle-add");
|
||||
expect(container.querySelector("span.MuiButton-label").innerHTML).toEqual("Sign In");
|
||||
@@ -44,21 +50,28 @@ describe("App", () => {
|
||||
});
|
||||
|
||||
it("Route / authenticated", async () => {
|
||||
setToken(TEST_TOKEN);
|
||||
setToken(TEST_AUTH_OBJECT);
|
||||
const container = await renderRoute("/");
|
||||
expect(container.querySelector("h1").innerHTML).toEqual("Upload Update Package");
|
||||
expect(container.querySelector("h1").innerHTML).toEqual("Welcome John!");
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Route /home authenticated", async () => {
|
||||
setToken(TEST_TOKEN);
|
||||
setToken(TEST_AUTH_OBJECT);
|
||||
const container = await renderRoute("/home");
|
||||
expect(container.querySelector("h1").innerHTML).toEqual("Welcome John!");
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Route /package-upload authenticated", async () => {
|
||||
setToken(TEST_AUTH_OBJECT);
|
||||
const container = await renderRoute("/package-upload");
|
||||
expect(container.querySelector("h1").innerHTML).toEqual("Upload Update Package");
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Route /vehicle-add authenticated", async () => {
|
||||
setToken(TEST_TOKEN);
|
||||
setToken(TEST_AUTH_OBJECT);
|
||||
const container = await renderRoute("/vehicle-add");
|
||||
expect(container.querySelector("h1").innerHTML).toEqual("Add Vehicle");
|
||||
expect(container).toMatchSnapshot();
|
||||
@@ -71,7 +84,7 @@ describe("App", () => {
|
||||
});
|
||||
|
||||
it("Route /page-not-found authenticated", async () => {
|
||||
setToken(TEST_TOKEN);
|
||||
setToken(TEST_AUTH_OBJECT);
|
||||
const container = await renderRoute("/page-not-found");
|
||||
expect(container.querySelector("h1").innerHTML).toEqual("Page Not Found");
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user