Files
ThreadNet-Web/apps/web/__mocks__/maplibre-gl.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.3 KiB
JavaScript
Raw Normal View History

/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
Copyright 2022 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
2024-09-09 14:57:16 +01:00
Please see LICENSE files in the repository root for full details.
*/
2026-08-04 10:15:07 +01:00
const EventEmitter = require("node:events");
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();
zoomIn = jest.fn();
zoomOut = jest.fn();
setCenter = jest.fn();
setStyle = jest.fn();
fitBounds = jest.fn();
remove = 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-18 23:17:15 +00: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();
const MockMarker = {};
MockMarker.setLngLat = jest.fn().mockReturnValue(MockMarker);
MockMarker.addTo = jest.fn().mockReturnValue(MockMarker);
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,
LngLatBounds,
NavigationControl,
2022-12-18 23:17:15 +00:00
AttributionControl: MockAttributionControl,
2022-03-02 14:00:40 +01:00
};