From dd0bce2f5d1573c19547089b00f15f5f673d8fd3 Mon Sep 17 00:00:00 2001 From: pauladamseniii Date: Wed, 18 Oct 2023 00:04:53 -0400 Subject: [PATCH] tests --- .../Add/__snapshots__/index.test.jsx.snap | 92 +++++++++++++ src/components/SUMS/Add/index.test.jsx | 46 +++++++ .../SUMS/__snapshots__/index.test.jsx.snap | 123 ++++++++++++++++++ src/components/SUMS/index.jsx | 4 +- src/components/SUMS/index.test.jsx | 46 +++++++ 5 files changed, 309 insertions(+), 2 deletions(-) create mode 100644 src/components/SUMS/Add/__snapshots__/index.test.jsx.snap create mode 100644 src/components/SUMS/Add/index.test.jsx create mode 100644 src/components/SUMS/__snapshots__/index.test.jsx.snap create mode 100644 src/components/SUMS/index.test.jsx diff --git a/src/components/SUMS/Add/__snapshots__/index.test.jsx.snap b/src/components/SUMS/Add/__snapshots__/index.test.jsx.snap new file mode 100644 index 0000000..1a38a9d --- /dev/null +++ b/src/components/SUMS/Add/__snapshots__/index.test.jsx.snap @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SUMSAdd Render 1`] = ` +
+
+
+
+
+
+
+
+ +
+ + +
+
+ +
+
+
+
+
+
+
+`; diff --git a/src/components/SUMS/Add/index.test.jsx b/src/components/SUMS/Add/index.test.jsx new file mode 100644 index 0000000..dd85da0 --- /dev/null +++ b/src/components/SUMS/Add/index.test.jsx @@ -0,0 +1,46 @@ +jest.mock("../../Contexts/CarUpdatesContext"); +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 { BrowserRouter } from "react-router-dom"; + +import { CarUpdatesProvider } from "../../Contexts/CarUpdatesContext"; +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 renderSUMSAdd = async () => { + const { container } = render( + + + + + + + + + + ); + await waitFor(() => { + /* render */ + }); + return container; +}; + +describe("SUMSAdd", () => { + beforeAll(() => { + addSnapshotSerializer(expect); + }); + + it("Render", async () => { + setToken(TEST_AUTH_OBJECT_FISKER); + const container = await renderSUMSAdd(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/src/components/SUMS/__snapshots__/index.test.jsx.snap b/src/components/SUMS/__snapshots__/index.test.jsx.snap new file mode 100644 index 0000000..8d02277 --- /dev/null +++ b/src/components/SUMS/__snapshots__/index.test.jsx.snap @@ -0,0 +1,123 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SUMS Render 1`] = ` +
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + +
+ + RXSWIN (RX Software Identification Number) + + + + + Created + + +
+
+
+
+
+
+
+
+`; diff --git a/src/components/SUMS/index.jsx b/src/components/SUMS/index.jsx index b8efb42..3b757b3 100644 --- a/src/components/SUMS/index.jsx +++ b/src/components/SUMS/index.jsx @@ -154,7 +154,7 @@ const MainForm = () => { onSortRequest={handleSort} /> - {versionRxSwins.map((row, index) => ( + {versionRxSwins && versionRxSwins.map((row, index) => ( {row.rxswin} @@ -183,7 +183,7 @@ const MainForm = () => { - {versionRxSwins.length === 0 ? ( + {!versionRxSwins || versionRxSwins.length === 0 ? ( No RX Identification Numbers ) : ( + jest.fn().mockReturnValue("mui-test-id") +); + +import { render, waitFor } from "@testing-library/react"; +import { BrowserRouter } from "react-router-dom"; + +import { CarUpdatesProvider } from "../Contexts/CarUpdatesContext"; +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 renderSUMS = async () => { + const { container } = render( + + + + + + + + + + ); + await waitFor(() => { + /* render */ + }); + return container; +}; + +describe("SUMS", () => { + beforeAll(() => { + addSnapshotSerializer(expect); + }); + + it("Render", async () => { + setToken(TEST_AUTH_OBJECT_FISKER); + const container = await renderSUMS(); + expect(container).toMatchSnapshot(); + }); +});