2022-03-02 13:00:40 +00:00
|
|
|
const EventEmitter = require("events");
|
2022-04-19 11:35:39 +00:00
|
|
|
const { LngLat, NavigationControl, LngLatBounds } = require('maplibre-gl');
|
2022-03-02 13:00:40 +00:00
|
|
|
|
|
|
|
class MockMap extends EventEmitter {
|
|
|
|
addControl = jest.fn();
|
|
|
|
removeControl = jest.fn();
|
2022-04-11 08:29:07 +00:00
|
|
|
zoomIn = jest.fn();
|
|
|
|
zoomOut = jest.fn();
|
2022-04-11 16:40:06 +00:00
|
|
|
setCenter = jest.fn();
|
|
|
|
setStyle = jest.fn();
|
2022-04-19 11:35:39 +00:00
|
|
|
fitBounds = jest.fn();
|
2022-03-02 13:00:40 +00:00
|
|
|
}
|
2022-03-09 17:14:07 +00:00
|
|
|
const MockMapInstance = new MockMap();
|
2022-03-02 13:00:40 +00:00
|
|
|
|
2022-03-09 17:14:07 +00:00
|
|
|
class MockGeolocateControl extends EventEmitter {
|
|
|
|
trigger = jest.fn();
|
2022-03-02 13:00:40 +00:00
|
|
|
}
|
2022-03-09 17:14:07 +00:00
|
|
|
const MockGeolocateInstance = new MockGeolocateControl();
|
|
|
|
const MockMarker = {}
|
|
|
|
MockMarker.setLngLat = jest.fn().mockReturnValue(MockMarker);
|
|
|
|
MockMarker.addTo = jest.fn().mockReturnValue(MockMarker);
|
2022-04-11 08:29:24 +00:00
|
|
|
MockMarker.remove = jest.fn().mockReturnValue(MockMarker);
|
2022-03-02 13:00:40 +00:00
|
|
|
module.exports = {
|
2022-03-09 17:14:07 +00:00
|
|
|
Map: jest.fn().mockReturnValue(MockMapInstance),
|
|
|
|
GeolocateControl: jest.fn().mockReturnValue(MockGeolocateInstance),
|
|
|
|
Marker: jest.fn().mockReturnValue(MockMarker),
|
2022-03-02 13:00:40 +00:00
|
|
|
LngLat,
|
2022-04-19 11:35:39 +00:00
|
|
|
LngLatBounds,
|
2022-04-11 08:29:24 +00:00
|
|
|
NavigationControl,
|
2022-03-02 13:00:40 +00:00
|
|
|
};
|