diff --git a/src/drawing/kml/kmllayer.test.ts b/src/drawing/kml/kmllayer.test.ts new file mode 100644 index 000000000..81ad9ba45 --- /dev/null +++ b/src/drawing/kml/kmllayer.test.ts @@ -0,0 +1,29 @@ +/** + * Copyright 2019 Google LLC. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { initialize } from "../../index"; +import { KmlLayer } from "./kmllayer"; + +test("can initialize", () => { + initialize(); + expect(new google.maps.KmlLayer()).toBeTruthy(); +}); + +test("mockInstances available", () => { + initialize(); + const kmllayer = new google.maps.KmlLayer(); + expect(KmlLayer.mockInstances).toMatchObject([kmllayer]); +}); diff --git a/src/drawing/kml/kmllayer.ts b/src/drawing/kml/kmllayer.ts new file mode 100644 index 000000000..15e04726e --- /dev/null +++ b/src/drawing/kml/kmllayer.ts @@ -0,0 +1,70 @@ +/** + * Copyright 2022 Google LLC. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LatLngBounds } from "../../maps/coordinates/latlng"; +import { MapsEventListener } from "../../maps/event/event"; +import { MVCObject } from "../../maps/event/mvcobject"; + +export class KmlLayer extends MVCObject implements google.maps.KmlLayer { + public getDefaultViewport = jest + .fn() + .mockImplementation((): LatLngBounds | null => null); + public getMap = jest + .fn() + .mockImplementation( + (): google.maps.Map | google.maps.StreetViewPanorama | null | undefined => + null + ); + public getMetadata = jest + .fn() + .mockImplementation((): google.maps.KmlLayerMetadata | null => null); + public getStatus = jest + .fn() + .mockImplementation((): google.maps.KmlLayerStatus | null => null); + public getUrl = jest + .fn() + .mockImplementation((): string | null | undefined => null); + public getZIndex = jest + .fn() + .mockImplementation((): number | null | undefined => null); + public setMap = jest + .fn() + .mockImplementation((map: google.maps.Map | null): void => { + return; + }); + public setOptions = jest + .fn() + .mockImplementation((options: google.maps.KmlLayerOptions): void => { + return; + }); + public setUrl = jest.fn().mockImplementation((url: string): void => { + return; + }); + public setZIndex = jest.fn().mockImplementation((zIndex: number): void => { + return; + }); + public addListener = jest + .fn() + .mockImplementation( + ( + eventName: string, + handler: (this: KmlLayer, event: MouseEvent) => void + ): google.maps.MapsEventListener => MapsEventListener + ); + constructor(opts?: google.maps.KmlLayerOptions | null) { + super(); + } +} diff --git a/src/index.ts b/src/index.ts index 21e4b66f7..1341849f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,6 +29,7 @@ import { MapPanes } from "./drawing/DOM/mappanes"; import { Map_ } from "./maps/maps/map"; import { Marker } from "./drawing/marker/marker"; import { OverlayView } from "./drawing/DOM/overlayview"; +import { KmlLayer } from "./drawing/kml/kmllayer"; import { Point } from "./maps/coordinates/point"; import { Polygon } from "./drawing/polygons/polygon"; import { Polyline } from "./drawing/polygons/polyline"; @@ -80,6 +81,7 @@ const initialize = function (): void { Polyline: Polyline, Circle: Circle, OverlayView: OverlayView, + KmlLayer: KmlLayer, MapCanvasProjection: MapCanvasProjection, MapPanes: MapPanes, VisibleRegion: VisibleRegion, @@ -102,6 +104,7 @@ export { Map_ as Map, Marker, OverlayView, + KmlLayer, Point, Polygon, Polyline,