From 68ac95b33b1f7b76d6a6954aa5cd0ef2c9d751f3 Mon Sep 17 00:00:00 2001 From: Tristan Timblin Date: Wed, 14 Jun 2023 18:08:45 -0400 Subject: [PATCH] add VehicleConsumer mock (#359) --- .../App/__snapshots__/App.test.js.snap | 74 ++++++++++++++- .../List/__snapshots__/index.test.jsx.snap | 74 ++++++++++++++- src/components/Cars/List/index.jsx | 6 +- src/components/Contexts/VehicleContext.jsx | 3 +- .../Contexts/__mocks__/VehicleContext.jsx | 4 + .../__snapshots__/index.test.jsx.snap | 91 ++++--------------- .../Controls/DropDownButton/index.test.jsx | 2 +- 7 files changed, 170 insertions(+), 84 deletions(-) diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index 08771e4..7cc160d 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -12198,7 +12198,7 @@ exports[`App Route /vehicles authenticated 1`] = ` class="MuiGrid-root makeStyles-root-0 MuiGrid-container MuiGrid-spacing-xs-2" >
+
+ + +
+ +
); }; diff --git a/src/components/Contexts/VehicleContext.jsx b/src/components/Contexts/VehicleContext.jsx index 6967a34..6a45be8 100644 --- a/src/components/Contexts/VehicleContext.jsx +++ b/src/components/Contexts/VehicleContext.jsx @@ -4,7 +4,8 @@ import { logger } from "../../services/monitoring"; import api from "../../services/vehiclesAPI"; import { validateVIN } from "../../utils/validationSupplier"; -export const VehicleContext = React.createContext(); +const VehicleContext = React.createContext(); +export const VehicleConsumer = VehicleContext.Consumer; const validateAdd = (vehicle) => { if (vehicle == null) { diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx index 1fca329..cfa6f0d 100644 --- a/src/components/Contexts/__mocks__/VehicleContext.jsx +++ b/src/components/Contexts/__mocks__/VehicleContext.jsx @@ -92,6 +92,10 @@ export const VehicleProvider = ({ children }) => { return
{children}
; }; +export const VehicleConsumer = ({ children }) => { + return children(); +}; + export const useVehicleContext = () => ({ busy, models, diff --git a/src/components/Controls/DropDownButton/__snapshots__/index.test.jsx.snap b/src/components/Controls/DropDownButton/__snapshots__/index.test.jsx.snap index a4d6165..80616fa 100644 --- a/src/components/Controls/DropDownButton/__snapshots__/index.test.jsx.snap +++ b/src/components/Controls/DropDownButton/__snapshots__/index.test.jsx.snap @@ -1,101 +1,42 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DownloadFileLink Render 1`] = ` -
-
- - -
-
-`; - exports[`DropDownButton Render 1`] = `
diff --git a/src/components/Controls/DropDownButton/index.test.jsx b/src/components/Controls/DropDownButton/index.test.jsx index 570c51f..32de737 100644 --- a/src/components/Controls/DropDownButton/index.test.jsx +++ b/src/components/Controls/DropDownButton/index.test.jsx @@ -53,7 +53,7 @@ describe("DropDownButton", () => { await waitFor(() => { /* render */ }); - const buttonEl = getByText("Disabled Action").parentElement; + const buttonEl = getByText("Disabled Action"); expect(buttonEl).toHaveProperty("disabled", true); });