Skip to content

Commit 9dcfd50

Browse files
authored
feat: adds KmlLayer mocks (#235)
1 parent f3ff6bf commit 9dcfd50

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

src/drawing/kml/kmllayer.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2019 Google LLC. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { initialize } from "../../index";
18+
import { KmlLayer } from "./kmllayer";
19+
20+
test("can initialize", () => {
21+
initialize();
22+
expect(new google.maps.KmlLayer()).toBeTruthy();
23+
});
24+
25+
test("mockInstances available", () => {
26+
initialize();
27+
const kmllayer = new google.maps.KmlLayer();
28+
expect(KmlLayer.mockInstances).toMatchObject([kmllayer]);
29+
});

src/drawing/kml/kmllayer.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Copyright 2022 Google LLC. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { LatLngBounds } from "../../maps/coordinates/latlng";
18+
import { MapsEventListener } from "../../maps/event/event";
19+
import { MVCObject } from "../../maps/event/mvcobject";
20+
21+
export class KmlLayer extends MVCObject implements google.maps.KmlLayer {
22+
public getDefaultViewport = jest
23+
.fn()
24+
.mockImplementation((): LatLngBounds | null => null);
25+
public getMap = jest
26+
.fn()
27+
.mockImplementation(
28+
(): google.maps.Map | google.maps.StreetViewPanorama | null | undefined =>
29+
null
30+
);
31+
public getMetadata = jest
32+
.fn()
33+
.mockImplementation((): google.maps.KmlLayerMetadata | null => null);
34+
public getStatus = jest
35+
.fn()
36+
.mockImplementation((): google.maps.KmlLayerStatus | null => null);
37+
public getUrl = jest
38+
.fn()
39+
.mockImplementation((): string | null | undefined => null);
40+
public getZIndex = jest
41+
.fn()
42+
.mockImplementation((): number | null | undefined => null);
43+
public setMap = jest
44+
.fn()
45+
.mockImplementation((map: google.maps.Map | null): void => {
46+
return;
47+
});
48+
public setOptions = jest
49+
.fn()
50+
.mockImplementation((options: google.maps.KmlLayerOptions): void => {
51+
return;
52+
});
53+
public setUrl = jest.fn().mockImplementation((url: string): void => {
54+
return;
55+
});
56+
public setZIndex = jest.fn().mockImplementation((zIndex: number): void => {
57+
return;
58+
});
59+
public addListener = jest
60+
.fn()
61+
.mockImplementation(
62+
(
63+
eventName: string,
64+
handler: (this: KmlLayer, event: MouseEvent) => void
65+
): google.maps.MapsEventListener => MapsEventListener
66+
);
67+
constructor(opts?: google.maps.KmlLayerOptions | null) {
68+
super();
69+
}
70+
}

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { MapPanes } from "./drawing/DOM/mappanes";
2929
import { Map_ } from "./maps/maps/map";
3030
import { Marker } from "./drawing/marker/marker";
3131
import { OverlayView } from "./drawing/DOM/overlayview";
32+
import { KmlLayer } from "./drawing/kml/kmllayer";
3233
import { Point } from "./maps/coordinates/point";
3334
import { Polygon } from "./drawing/polygons/polygon";
3435
import { Polyline } from "./drawing/polygons/polyline";
@@ -80,6 +81,7 @@ const initialize = function (): void {
8081
Polyline: Polyline,
8182
Circle: Circle,
8283
OverlayView: OverlayView,
84+
KmlLayer: KmlLayer,
8385
MapCanvasProjection: MapCanvasProjection,
8486
MapPanes: MapPanes,
8587
VisibleRegion: VisibleRegion,
@@ -102,6 +104,7 @@ export {
102104
Map_ as Map,
103105
Marker,
104106
OverlayView,
107+
KmlLayer,
105108
Point,
106109
Polygon,
107110
Polyline,

0 commit comments

Comments
 (0)