Skip to content

Commit 83a0d65

Browse files
authored
fix: getBounds correct return value (#84)
1 parent 8724502 commit 83a0d65

File tree

1 file changed

+61
-40
lines changed

1 file changed

+61
-40
lines changed

src/map.ts

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { LatLng } from "./latlng";
17+
import { LatLng, LatLngBounds } from "./latlng";
18+
1819
import { MVCObject } from "./mvcobject";
1920

2021
export class Map_ extends MVCObject implements google.maps.Map {
@@ -26,89 +27,109 @@ export class Map_ extends MVCObject implements google.maps.Map {
2627
constructor(mapDiv: Element | null, opts?: google.maps.MapOptions) {
2728
super();
2829
}
29-
fitBounds = jest
30+
public fitBounds = jest
3031
.fn()
3132
.mockImplementation(
3233
(
3334
bounds: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral,
3435
padding?: number | google.maps.Padding
35-
): void => {}
36+
): void => {
37+
return null;
38+
}
3639
);
37-
getBounds = jest
38-
.fn()
39-
.mockImplementation(
40-
(): google.maps.LatLngBounds | null | undefined => null
41-
);
42-
getCenter = jest
40+
public getBounds = jest.fn().mockImplementation(() => new LatLngBounds());
41+
public getCenter = jest
4342
.fn()
4443
.mockImplementation(
4544
(): google.maps.LatLng => new LatLng({ lat: 0, lng: 0 })
4645
);
47-
getClickableIcons = jest.fn().mockImplementation((): boolean => false);
48-
getDiv = jest.fn().mockImplementation((): Element => {
46+
public getClickableIcons = jest.fn().mockImplementation((): boolean => false);
47+
public getDiv = jest.fn().mockImplementation((): Element => {
4948
return jest.fn() as unknown as Element;
5049
});
51-
getHeading = jest.fn().mockImplementation((): number => 0);
52-
getMapTypeId = jest
50+
public getHeading = jest.fn().mockImplementation((): number => 0);
51+
public getMapTypeId = jest
5352
.fn()
5453
.mockImplementation(
5554
(): google.maps.MapTypeId => google.maps.MapTypeId.ROADMAP
5655
);
57-
getProjection = jest
56+
public getProjection = jest
5857
.fn()
5958
.mockImplementation((): google.maps.Projection | null => jest.fn() as null);
60-
getRenderingType = jest
59+
public getRenderingType = jest
6160
.fn()
6261
.mockImplementation(
6362
(): google.maps.RenderingType => google.maps.RenderingType.RASTER
6463
);
65-
getStreetView = jest
64+
public getStreetView = jest
6665
.fn()
6766
.mockImplementation(
6867
(): google.maps.StreetViewPanorama =>
6968
jest.fn() as unknown as google.maps.StreetViewPanorama
7069
);
71-
getTilt = jest.fn().mockImplementation((): number => 0);
72-
getZoom = jest.fn().mockImplementation((): number => 0);
73-
moveCamera = jest
70+
public getTilt = jest.fn().mockImplementation((): number => 0);
71+
public getZoom = jest.fn().mockImplementation((): number => 0);
72+
public moveCamera = jest
7473
.fn()
75-
.mockImplementation((cameraOptions: google.maps.CameraOptions): void => {});
76-
panBy = jest.fn().mockImplementation((x: number, y: number): void => {});
77-
panTo = jest
74+
.mockImplementation((cameraOptions: google.maps.CameraOptions): void => {
75+
return null;
76+
});
77+
public panBy = jest.fn().mockImplementation((x: number, y: number): void => {
78+
return null;
79+
});
80+
public panTo = jest
7881
.fn()
7982
.mockImplementation(
80-
(latLng: google.maps.LatLng | google.maps.LatLngLiteral): void => {}
83+
(latLng: google.maps.LatLng | google.maps.LatLngLiteral): void => {
84+
return null;
85+
}
8186
);
82-
panToBounds = jest
87+
public panToBounds = jest
8388
.fn()
8489
.mockImplementation(
8590
(
8691
latLngBounds:
8792
| google.maps.LatLngBounds
8893
| google.maps.LatLngBoundsLiteral,
8994
padding?: number | google.maps.Padding
90-
): void => {}
95+
): void => {
96+
return null;
97+
}
9198
);
92-
setCenter = jest
99+
public setCenter = jest
93100
.fn()
94101
.mockImplementation(
95-
(latlng: google.maps.LatLng | google.maps.LatLngLiteral): void => {}
102+
(latlng: google.maps.LatLng | google.maps.LatLngLiteral): void => {
103+
return null;
104+
}
96105
);
97-
setHeading = jest.fn().mockImplementation((heading: number): void => {});
98-
setMapTypeId = jest
106+
public setHeading = jest.fn().mockImplementation((heading: number): void => {
107+
return null;
108+
});
109+
public setMapTypeId = jest
99110
.fn()
100-
.mockImplementation(
101-
(mapTypeId: google.maps.MapTypeId | string): void => {}
102-
);
103-
setOptions = jest
111+
.mockImplementation((mapTypeId: google.maps.MapTypeId | string): void => {
112+
return null;
113+
});
114+
public setOptions = jest
104115
.fn()
105-
.mockImplementation((options: google.maps.MapOptions): void => {});
106-
setStreetView = jest
116+
.mockImplementation((options: google.maps.MapOptions): void => {
117+
return null;
118+
});
119+
public setStreetView = jest
107120
.fn()
108-
.mockImplementation((panorama: google.maps.StreetViewPanorama): void => {});
109-
setTilt = jest.fn().mockImplementation((tilt: number): void => {});
110-
setZoom = jest.fn().mockImplementation((zoom: number): void => {});
111-
setClickableIcons = jest
121+
.mockImplementation((panorama: google.maps.StreetViewPanorama): void => {
122+
return null;
123+
});
124+
public setTilt = jest.fn().mockImplementation((tilt: number): void => {
125+
return null;
126+
});
127+
public setZoom = jest.fn().mockImplementation((zoom: number): void => {
128+
return null;
129+
});
130+
public setClickableIcons = jest
112131
.fn()
113-
.mockImplementation((clickable: boolean): void => {});
132+
.mockImplementation((clickable: boolean): void => {
133+
return null;
134+
});
114135
}

0 commit comments

Comments
 (0)