mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Test ControlPointsLayer.
This commit is contained in:
parent
647d1f57f9
commit
b1af6dfbe1
@ -0,0 +1,52 @@
|
|||||||
|
import { renderWithProviders } from "../../testutils";
|
||||||
|
import ControlPointsLayer from "./ControlPointsLayer";
|
||||||
|
import { LatLng } from "leaflet";
|
||||||
|
import { PropsWithChildren } from "react";
|
||||||
|
|
||||||
|
const mockMarker = jest.fn();
|
||||||
|
const mockLayerGroup = jest.fn();
|
||||||
|
jest.mock("react-leaflet", () => ({
|
||||||
|
LayerGroup: (props: PropsWithChildren<any>) => {
|
||||||
|
mockLayerGroup(props);
|
||||||
|
return <>{props.children}</>;
|
||||||
|
},
|
||||||
|
Marker: (props: any) => {
|
||||||
|
mockMarker(props);
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("ControlPointsLayer", () => {
|
||||||
|
it("renders each control point", () => {
|
||||||
|
renderWithProviders(<ControlPointsLayer />, {
|
||||||
|
preloadedState: {
|
||||||
|
controlPoints: {
|
||||||
|
controlPoints: {
|
||||||
|
foo: {
|
||||||
|
id: "foo",
|
||||||
|
name: "Foo",
|
||||||
|
blue: true,
|
||||||
|
position: new LatLng(0, 0),
|
||||||
|
mobile: false,
|
||||||
|
sidc: "",
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
id: "bar",
|
||||||
|
name: "Bar",
|
||||||
|
blue: false,
|
||||||
|
position: new LatLng(1, 0),
|
||||||
|
mobile: false,
|
||||||
|
sidc: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(mockMarker).toBeCalledTimes(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders LayerGroup but no contents if no combat", () => {
|
||||||
|
renderWithProviders(<ControlPointsLayer />);
|
||||||
|
expect(mockLayerGroup).toBeCalledTimes(1);
|
||||||
|
expect(mockMarker).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user