From b45c70bd52713902a15b03bd7f0f9704cb5f0eb3 Mon Sep 17 00:00:00 2001 From: Alexander Andrews <45926661+alexander-e-andrews@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:08:18 -0400 Subject: [PATCH] CEC-2654: Map polls for curren visible area (#222) Update index.jsx Added some tests, still don't meet threshold Co-authored-by: Alexander Andrews --- src/components/Contexts/VehicleContext.jsx | 4 +- .../Contexts/VehicleContext.test.jsx | 53 +++++++ .../__snapshots__/index.test.jsx.snap | 130 ++++++++++++++++++ .../__snapshots__/popup.test.jsx.snap | 7 + src/components/VehicleMap/index.jsx | 85 +++++++----- src/components/VehicleMap/index.test.jsx | 30 ++++ src/components/VehicleMap/popup.jsx | 4 +- src/components/VehicleMap/popup.test.jsx | 43 ++++++ src/services/__mocks__/vehiclesAPI.js | 8 +- src/services/vehiclesAPI.js | 5 +- 10 files changed, 324 insertions(+), 45 deletions(-) create mode 100644 src/components/VehicleMap/__snapshots__/index.test.jsx.snap create mode 100644 src/components/VehicleMap/__snapshots__/popup.test.jsx.snap create mode 100644 src/components/VehicleMap/index.test.jsx create mode 100644 src/components/VehicleMap/popup.test.jsx diff --git a/src/components/Contexts/VehicleContext.jsx b/src/components/Contexts/VehicleContext.jsx index 3896f9d..e525ef7 100644 --- a/src/components/Contexts/VehicleContext.jsx +++ b/src/components/Contexts/VehicleContext.jsx @@ -89,10 +89,10 @@ export const VehicleProvider = ({ children }) => { } }; - const getLocations = async (token) => { + const getLocations = async (token, mapLocationInfo) => { try { setBusy(true); - const result = await api.getLocations(token); + const result = await api.getLocations(token, mapLocationInfo); if (result.error) throw new Error(`Get locations error. ${result.message}`); return result; diff --git a/src/components/Contexts/VehicleContext.test.jsx b/src/components/Contexts/VehicleContext.test.jsx index a8c79d5..867d8d9 100644 --- a/src/components/Contexts/VehicleContext.test.jsx +++ b/src/components/Contexts/VehicleContext.test.jsx @@ -9,6 +9,7 @@ import { } from "@testing-library/react"; import { VehicleProvider, useVehicleContext } from "./VehicleContext"; import { StatusProvider, useStatusContext } from "./StatusContext"; +import { act } from "react-dom/test-utils"; const checkVehicleResult = (error, busy, vehicle) => { checkBaseResults(error, busy); @@ -437,6 +438,56 @@ describe("VehicleContext", () => { checkBaseResults("", "false"); }); }); + + describe("Get Locations", () => { + var locationFilter = { + center: { + longitude: 0, + latitude: 0 + }, + width: 0, + height: 0 + } + + var locations; + beforeEach(() => { + const TestComp = () => { + const { busy, error, getLocations } = useVehicleContext(); + + return ( + <> +
{error}
+
{busy.toString()}
+