-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjest.stub.js
More file actions
32 lines (28 loc) · 940 Bytes
/
jest.stub.js
File metadata and controls
32 lines (28 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* global globalThis */
globalThis.mockMapGL = {
on: jest.fn(),
addLayer: jest.fn(),
addSource: jest.fn(),
addControl: jest.fn(),
getLayer: jest.fn(),
getSource: jest.fn(),
setFeatureState: jest.fn(),
getCanvas: jest.fn(() => ({ style: {} })),
_getUIString: jest.fn(),
}
globalThis.mockMap = {
getMapGL: () => globalThis.mockMapGL,
setHoverState: jest.fn(),
getBeforeLayerId: jest.fn(),
styleIsLoaded: () => true,
}
// https://stackoverflow.com/questions/57943736/how-to-fix-window-url-createobjecturl-is-not-a-function-when-testing-mapbox-gl
globalThis.URL.createObjectURL ??= () => {}
// Provide TextEncoder/TextDecoder for maplibre and related libs
const { TextEncoder, TextDecoder } = require('node:util')
if (globalThis.TextEncoder === undefined) {
globalThis.TextEncoder = TextEncoder
}
if (globalThis.TextDecoder === undefined) {
globalThis.TextDecoder = TextDecoder
}