From 3d88636de79296c8461e6dea07cbbe9d5736f024 Mon Sep 17 00:00:00 2001 From: padamsen_fisker Date: Wed, 17 Jan 2024 10:33:02 -0500 Subject: [PATCH] unit tests --- .../Add/__snapshots__/index.test.jsx.snap | 293 ++++++++++++++++++ src/components/Flashpack/Add/index.test.jsx | 46 +++ .../Details/__snapshots__/index.test.jsx.snap | 99 ++++++ .../Flashpack/Details/index.test.jsx | 46 +++ .../__snapshots__/index.test.jsx.snap | 152 +++++++++ src/components/Flashpack/index.jsx | 3 + src/components/Flashpack/index.test.jsx | 46 +++ 7 files changed, 685 insertions(+) create mode 100644 src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap create mode 100644 src/components/Flashpack/Add/index.test.jsx create mode 100644 src/components/Flashpack/Details/__snapshots__/index.test.jsx.snap create mode 100644 src/components/Flashpack/Details/index.test.jsx create mode 100644 src/components/Flashpack/__snapshots__/index.test.jsx.snap create mode 100644 src/components/Flashpack/index.test.jsx diff --git a/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap new file mode 100644 index 0000000..bcb5f26 --- /dev/null +++ b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap @@ -0,0 +1,293 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FlashpackAdd Render 1`] = ` +
+
+
+
+
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+
+
+ +
+
+
+
+
+
+
+`; diff --git a/src/components/Flashpack/Add/index.test.jsx b/src/components/Flashpack/Add/index.test.jsx new file mode 100644 index 0000000..ba1235b --- /dev/null +++ b/src/components/Flashpack/Add/index.test.jsx @@ -0,0 +1,46 @@ +jest.mock("../../Contexts/VehicleContext"); +jest.mock("../../Contexts/StatusContext"); +jest.mock("../../Contexts/UserContext"); +jest.mock("@material-ui/core/utils/unstable_useId", () => + jest.fn().mockReturnValue("mui-test-id") +); +import { render, waitFor } from "@testing-library/react"; +import { MemoryRouter, Route } from "react-router-dom"; +import { VehicleProvider } from "../../Contexts/VehicleContext"; +import { StatusProvider } from "../../Contexts/StatusContext"; +import { UserProvider, setToken } from "../../Contexts/UserContext"; +import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing"; +import MainForm from "./index"; +import addSnapshotSerializer from "../../../utils/snapshot"; + +const renderFlashpackAdd = async () => { + const { container } = render( + + + + + + + + + + + + ); + await waitFor(() => { + /* render */ + }); + return container; +}; + +describe("FlashpackAdd", () => { + beforeAll(() => { + addSnapshotSerializer(expect); + }); + + it("Render", async () => { + setToken(TEST_AUTH_OBJECT_FISKER); + const container = await renderFlashpackAdd(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/src/components/Flashpack/Details/__snapshots__/index.test.jsx.snap b/src/components/Flashpack/Details/__snapshots__/index.test.jsx.snap new file mode 100644 index 0000000..303487f --- /dev/null +++ b/src/components/Flashpack/Details/__snapshots__/index.test.jsx.snap @@ -0,0 +1,99 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FlashpackDetails Render 1`] = ` +
+
+
+
+
+
+ + + + + + + + + + + + + +
+ + ECU Name + + + + + ECU Version + + +
+
+
+
+
+
+
+`; diff --git a/src/components/Flashpack/Details/index.test.jsx b/src/components/Flashpack/Details/index.test.jsx new file mode 100644 index 0000000..b0f11fb --- /dev/null +++ b/src/components/Flashpack/Details/index.test.jsx @@ -0,0 +1,46 @@ +jest.mock("../../Contexts/VehicleContext"); +jest.mock("../../Contexts/StatusContext"); +jest.mock("../../Contexts/UserContext"); +jest.mock("@material-ui/core/utils/unstable_useId", () => + jest.fn().mockReturnValue("mui-test-id") +); +import { render, waitFor } from "@testing-library/react"; +import { MemoryRouter, Route } from "react-router-dom"; +import { VehicleProvider } from "../../Contexts/VehicleContext"; +import { StatusProvider } from "../../Contexts/StatusContext"; +import { UserProvider, setToken } from "../../Contexts/UserContext"; +import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing"; +import MainForm from "./index"; +import addSnapshotSerializer from "../../../utils/snapshot"; + +const renderFlashpackDetails = async () => { + const { container } = render( + + + + + + + + + + + + ); + await waitFor(() => { + /* render */ + }); + return container; +}; + +describe("FlashpackDetails", () => { + beforeAll(() => { + addSnapshotSerializer(expect); + }); + + it("Render", async () => { + setToken(TEST_AUTH_OBJECT_FISKER); + const container = await renderFlashpackDetails(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/src/components/Flashpack/__snapshots__/index.test.jsx.snap b/src/components/Flashpack/__snapshots__/index.test.jsx.snap new file mode 100644 index 0000000..85aac96 --- /dev/null +++ b/src/components/Flashpack/__snapshots__/index.test.jsx.snap @@ -0,0 +1,152 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Flashpack Render 1`] = ` +
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + +
+ + Flashpack Number + + sorted descending + + + + + + Model + + + + + Year + + +
+
+
+
+
+
+
+
+`; diff --git a/src/components/Flashpack/index.jsx b/src/components/Flashpack/index.jsx index b403782..4534d8b 100644 --- a/src/components/Flashpack/index.jsx +++ b/src/components/Flashpack/index.jsx @@ -137,7 +137,10 @@ const MainForm = () => { {flashpacks && flashpacks.map((row, index) => ( diff --git a/src/components/Flashpack/index.test.jsx b/src/components/Flashpack/index.test.jsx new file mode 100644 index 0000000..1d282cf --- /dev/null +++ b/src/components/Flashpack/index.test.jsx @@ -0,0 +1,46 @@ +jest.mock("../Contexts/VehicleContext"); +jest.mock("../Contexts/StatusContext"); +jest.mock("../Contexts/UserContext"); +jest.mock("@material-ui/core/utils/unstable_useId", () => + jest.fn().mockReturnValue("mui-test-id") +); +import { render, waitFor } from "@testing-library/react"; +import { MemoryRouter, Route } from "react-router-dom"; +import { VehicleProvider } from "../Contexts/VehicleContext"; +import { StatusProvider } from "../Contexts/StatusContext"; +import { UserProvider, setToken } from "../Contexts/UserContext"; +import { TEST_AUTH_OBJECT_FISKER } from "../../utils/testing"; +import MainForm from "./index"; +import addSnapshotSerializer from "../../utils/snapshot"; + +const renderFlashpack = async () => { + const { container } = render( + + + + + + + + + + + + ); + await waitFor(() => { + /* render */ + }); + return container; +}; + +describe("Flashpack", () => { + beforeAll(() => { + addSnapshotSerializer(expect); + }); + + it("Render", async () => { + setToken(TEST_AUTH_OBJECT_FISKER); + const container = await renderFlashpack(); + expect(container).toMatchSnapshot(); + }); +});