2022-06-17 21:27:08 +08:00
|
|
|
/*
|
2024-09-09 21:57:16 +08:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-06-17 21:27:08 +08:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 21:57:16 +08:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-06-17 21:27:08 +08:00
|
|
|
*/
|
|
|
|
|
2022-03-02 21:00:40 +08:00
|
|
|
const EventEmitter = require("events");
|
2023-05-12 19:13:08 +08:00
|
|
|
const { LngLat, NavigationControl, LngLatBounds } = require("maplibre-gl");
|
2022-03-02 21:00:40 +08:00
|
|
|
|
|
|
|
class MockMap extends EventEmitter {
|
|
|
|
addControl = jest.fn();
|
|
|
|
removeControl = jest.fn();
|
2022-04-11 16:29:07 +08:00
|
|
|
zoomIn = jest.fn();
|
|
|
|
zoomOut = jest.fn();
|
2022-04-12 00:40:06 +08:00
|
|
|
setCenter = jest.fn();
|
|
|
|
setStyle = jest.fn();
|
2022-04-19 19:35:39 +08:00
|
|
|
fitBounds = jest.fn();
|
2022-03-02 21:00:40 +08:00
|
|
|
}
|
2022-03-10 01:14:07 +08:00
|
|
|
const MockMapInstance = new MockMap();
|
2022-03-02 21:00:40 +08:00
|
|
|
|
2022-12-19 07:17:15 +08:00
|
|
|
class MockAttributionControl {}
|
2022-03-10 01:14:07 +08:00
|
|
|
class MockGeolocateControl extends EventEmitter {
|
|
|
|
trigger = jest.fn();
|
2022-03-02 21:00:40 +08:00
|
|
|
}
|
2022-03-10 01:14:07 +08:00
|
|
|
const MockGeolocateInstance = new MockGeolocateControl();
|
|
|
|
const MockMarker = {};
|
|
|
|
MockMarker.setLngLat = jest.fn().mockReturnValue(MockMarker);
|
|
|
|
MockMarker.addTo = jest.fn().mockReturnValue(MockMarker);
|
2022-04-11 16:29:24 +08:00
|
|
|
MockMarker.remove = jest.fn().mockReturnValue(MockMarker);
|
2022-03-02 21:00:40 +08:00
|
|
|
module.exports = {
|
2022-03-10 01:14:07 +08:00
|
|
|
Map: jest.fn().mockReturnValue(MockMapInstance),
|
|
|
|
GeolocateControl: jest.fn().mockReturnValue(MockGeolocateInstance),
|
|
|
|
Marker: jest.fn().mockReturnValue(MockMarker),
|
2022-03-02 21:00:40 +08:00
|
|
|
LngLat,
|
2022-04-19 19:35:39 +08:00
|
|
|
LngLatBounds,
|
2022-04-11 16:29:24 +08:00
|
|
|
NavigationControl,
|
2022-12-19 07:17:15 +08:00
|
|
|
AttributionControl: MockAttributionControl,
|
2022-03-02 21:00:40 +08:00
|
|
|
};
|