2022-06-17 15:27:08 +02:00
|
|
|
/*
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-03-02 14:00:40 +01:00
|
|
|
const EventEmitter = require("events");
|
2023-05-12 13:13:08 +02:00
|
|
|
const { LngLat, NavigationControl, LngLatBounds } = require("maplibre-gl");
|
2022-03-02 14:00:40 +01:00
|
|
|
|
|
|
|
class MockMap extends EventEmitter {
|
|
|
|
addControl = jest.fn();
|
|
|
|
removeControl = jest.fn();
|
2022-04-11 10:29:07 +02:00
|
|
|
zoomIn = jest.fn();
|
|
|
|
zoomOut = jest.fn();
|
2022-04-11 18:40:06 +02:00
|
|
|
setCenter = jest.fn();
|
|
|
|
setStyle = jest.fn();
|
2022-04-19 13:35:39 +02:00
|
|
|
fitBounds = jest.fn();
|
2022-03-02 14:00:40 +01:00
|
|
|
}
|
2022-03-09 18:14:07 +01:00
|
|
|
const MockMapInstance = new MockMap();
|
2022-03-02 14:00:40 +01:00
|
|
|
|
2022-12-19 00:17:15 +01:00
|
|
|
class MockAttributionControl {}
|
2022-03-09 18:14:07 +01:00
|
|
|
class MockGeolocateControl extends EventEmitter {
|
|
|
|
trigger = jest.fn();
|
2022-03-02 14:00:40 +01:00
|
|
|
}
|
2022-03-09 18:14:07 +01:00
|
|
|
const MockGeolocateInstance = new MockGeolocateControl();
|
2022-12-12 12:24:14 +01:00
|
|
|
const MockMarker = {};
|
2022-03-09 18:14:07 +01:00
|
|
|
MockMarker.setLngLat = jest.fn().mockReturnValue(MockMarker);
|
|
|
|
MockMarker.addTo = jest.fn().mockReturnValue(MockMarker);
|
2022-04-11 10:29:24 +02:00
|
|
|
MockMarker.remove = jest.fn().mockReturnValue(MockMarker);
|
2022-03-02 14:00:40 +01:00
|
|
|
module.exports = {
|
2022-03-09 18:14:07 +01:00
|
|
|
Map: jest.fn().mockReturnValue(MockMapInstance),
|
|
|
|
GeolocateControl: jest.fn().mockReturnValue(MockGeolocateInstance),
|
|
|
|
Marker: jest.fn().mockReturnValue(MockMarker),
|
2022-03-02 14:00:40 +01:00
|
|
|
LngLat,
|
2022-04-19 13:35:39 +02:00
|
|
|
LngLatBounds,
|
2022-04-11 10:29:24 +02:00
|
|
|
NavigationControl,
|
2022-12-19 00:17:15 +01:00
|
|
|
AttributionControl: MockAttributionControl,
|
2022-03-02 14:00:40 +01:00
|
|
|
};
|