diff --git a/src/drawing/polygons/polygon.test.ts b/src/drawing/polygons/polygon.test.ts index 19bc7297..49745ad9 100644 --- a/src/drawing/polygons/polygon.test.ts +++ b/src/drawing/polygons/polygon.test.ts @@ -32,12 +32,15 @@ test("getEditable returns false", () => { expect(new google.maps.Polygon(null).getEditable()).toBe(false); }); -test("getMap returns {}", () => { - expect(new google.maps.Polygon(null).getMap()).toEqual({}); +test("getMap returns null", () => { + expect(new google.maps.Polygon(null).getMap()).toEqual(null); }); -test("getPath returns {}", () => { - expect(new google.maps.Polygon(null).getPath()).toEqual({}); +test("getPath returns an MVCArray", () => { + const p = new google.maps.Polygon(null); + const path = p.getPath(); + + expect(path).toBeInstanceOf(google.maps.MVCArray); }); test("getPaths returns {}", () => { diff --git a/src/drawing/polygons/polygon.ts b/src/drawing/polygons/polygon.ts index 1ab75b33..daffb144 100644 --- a/src/drawing/polygons/polygon.ts +++ b/src/drawing/polygons/polygon.ts @@ -15,6 +15,7 @@ */ import { MVCObject } from "../../maps/event/mvcobject"; +import { MVCArray } from "../../maps/event/mvcarray"; export class Polygon extends MVCObject implements google.maps.Polygon { constructor(opts?: google.maps.PolygonOptions | null) { @@ -25,12 +26,11 @@ export class Polygon extends MVCObject implements google.maps.Polygon { public getEditable = jest.fn().mockImplementation((): boolean => false); public getMap = jest .fn() - .mockImplementation((): google.maps.Map => ({}) as google.maps.Map); + .mockImplementation((): google.maps.Map | null => null); public getPath = jest .fn() .mockImplementation( - (): google.maps.MVCArray => - ({}) as google.maps.MVCArray + (): google.maps.MVCArray => new MVCArray() ); public getPaths = jest .fn() @@ -47,7 +47,7 @@ export class Polygon extends MVCObject implements google.maps.Polygon { .mockImplementation((editable: boolean): void => {}); public setMap = jest .fn() - .mockImplementation((map: google.maps.Map): void => {}); + .mockImplementation((map: google.maps.Map | null): void => {}); public setOptions = jest .fn() .mockImplementation((options: google.maps.PolygonOptions): void => {}); diff --git a/src/drawing/polygons/polyline.ts b/src/drawing/polygons/polyline.ts index c9392b70..fcc14225 100644 --- a/src/drawing/polygons/polyline.ts +++ b/src/drawing/polygons/polyline.ts @@ -15,6 +15,7 @@ */ import { MVCObject } from "../../maps/event/mvcobject"; +import { MVCArray } from "../../maps/event/mvcarray"; export class Polyline extends MVCObject implements google.maps.Polyline { constructor(opts?: google.maps.PolylineOptions | null) { @@ -25,12 +26,11 @@ export class Polyline extends MVCObject implements google.maps.Polyline { public getEditable = jest.fn().mockImplementation((): boolean => false); public getMap = jest .fn() - .mockImplementation((): google.maps.Map => ({}) as google.maps.Map); + .mockImplementation((): google.maps.Map | null => null); public getPath = jest .fn() .mockImplementation( - (): google.maps.MVCArray => - ({}) as google.maps.MVCArray + (): google.maps.MVCArray => new MVCArray() ); public getVisible = jest.fn().mockImplementation((): boolean => false); public setDraggable = jest @@ -41,7 +41,7 @@ export class Polyline extends MVCObject implements google.maps.Polyline { .mockImplementation((editable: boolean): void => {}); public setMap = jest .fn() - .mockImplementation((map: google.maps.Map): void => {}); + .mockImplementation((map: google.maps.Map | null): void => {}); public setOptions = jest .fn() .mockImplementation((options: google.maps.PolylineOptions): void => {});