From e4e7155f027c43bcff29817e783b55c94a975b01 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 16 Jun 2023 12:31:38 -0700 Subject: [PATCH] Partial tests for FrontLine. We need to mock the backend to usefully test the contextmenu handler. I'd like to finish all the low hanging fruit before going for that. --- .../components/frontline/FrontLine.test.tsx | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 client/src/components/frontline/FrontLine.test.tsx diff --git a/client/src/components/frontline/FrontLine.test.tsx b/client/src/components/frontline/FrontLine.test.tsx new file mode 100644 index 00000000..62f4132a --- /dev/null +++ b/client/src/components/frontline/FrontLine.test.tsx @@ -0,0 +1,32 @@ +import { renderWithProviders } from "../../testutils"; +import FrontLine from "./FrontLine"; +import { PolylineProps } from "react-leaflet"; + +const mockPolyline = jest.fn(); +jest.mock("react-leaflet", () => ({ + Polyline: (props: PolylineProps) => { + mockPolyline(props); + }, +})); + +describe("FrontLine", () => { + it("is drawn in the correct location", () => { + const extents = [ + { lat: 0, lng: 0 }, + { lat: 1, lng: 0 }, + ]; + renderWithProviders( + + ); + expect(mockPolyline).toHaveBeenCalledWith( + expect.objectContaining({ + positions: extents, + }) + ); + }); +});