-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
78 lines (75 loc) · 1.98 KB
/
vitest.setup.ts
File metadata and controls
78 lines (75 loc) · 1.98 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import '@testing-library/jest-dom';
import { vi } from 'vitest';
// Mock maplibre-gl to avoid "Failed to initialize WebGL" errors
vi.mock('maplibre-gl', () => {
const Map = vi.fn(() => ({
on: vi.fn(),
off: vi.fn(),
remove: vi.fn(),
addControl: vi.fn(),
resize: vi.fn(),
flyTo: vi.fn(),
fitBounds: vi.fn(),
jumpTo: vi.fn(),
getContainer: vi.fn(() => document.createElement('div')),
loaded: vi.fn(() => true),
isStyleLoaded: vi.fn(() => true),
getCanvas: vi.fn(() => document.createElement('canvas')),
setStyle: vi.fn(),
setCenter: vi.fn(),
setZoom: vi.fn(),
getCenter: vi.fn(() => ({ lng: 0, lat: 0 })),
getZoom: vi.fn(() => 0),
addSource: vi.fn(),
removeSource: vi.fn(),
addLayer: vi.fn(),
removeLayer: vi.fn(),
setLayoutProperty: vi.fn(),
setPaintProperty: vi.fn(),
setFilter: vi.fn(),
queryRenderedFeatures: vi.fn(() => []),
}));
const NavigationControl = vi.fn();
const GeolocateControl = vi.fn();
const AttributionControl = vi.fn();
const ScaleControl = vi.fn();
const FullscreenControl = vi.fn();
const Popup = vi.fn(() => ({
setLngLat: vi.fn().mockReturnThis(),
setHTML: vi.fn().mockReturnThis(),
setText: vi.fn().mockReturnThis(),
setDOMContent: vi.fn().mockReturnThis(),
addTo: vi.fn().mockReturnThis(),
remove: vi.fn(),
}));
const Marker = vi.fn(() => ({
setLngLat: vi.fn().mockReturnThis(),
addTo: vi.fn().mockReturnThis(),
remove: vi.fn(),
setPopup: vi.fn().mockReturnThis(),
getElement: vi.fn(() => document.createElement('div')),
}));
const supported = vi.fn(() => true);
return {
default: {
Map,
NavigationControl,
GeolocateControl,
AttributionControl,
ScaleControl,
FullscreenControl,
Popup,
Marker,
supported,
},
Map,
NavigationControl,
GeolocateControl,
AttributionControl,
ScaleControl,
FullscreenControl,
Popup,
Marker,
supported,
};
});