-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathjest.setup.ts
36 lines (35 loc) · 1 KB
/
jest.setup.ts
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
// jest.setup.ts
global.google = {
maps: {
OverlayView: class {
onAdd(): void {}
draw(): void {}
onRemove(): void {}
// Mocking the missing methods to match the OverlayView interface
preventMapHitsAndGesturesFrom(_element: Element): void {}
preventMapHitsFrom(_element: Element): void {}
// If your code calls getPanes or getProjection, mock them as well
getPanes(): { overlayLayer: HTMLElement } {
return { overlayLayer: document.createElement("div") };
}
getProjection(): {
fromLatLngToDivPixel: (latLng: google.maps.LatLng) => {
x: number;
y: number;
};
} {
return {
fromLatLngToDivPixel: () => ({ x: 0, y: 0 }),
};
}
},
LatLng: class {
lat: number;
lng: number;
constructor(lat: number, lng: number) {
this.lat = lat;
this.lng = lng;
}
},
},
} as unknown as typeof google; // Use a type assertion to ensure correct typing