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.
This commit is contained in:
Dan Albert
2023-06-16 12:31:38 -07:00
committed by Raffson
parent c924130356
commit e4e7155f02

View File

@@ -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(
<FrontLine
front={{
id: "",
extents: extents,
}}
/>
);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
positions: extents,
})
);
});
});