Skip to content

Commit

Permalink
fix: polygon.getPath() should return an MVCArray (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulthink committed Nov 30, 2023
1 parent afe991e commit 3357752
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/drawing/polygons/polygon.test.ts
Expand Up @@ -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 {}", () => {
Expand Down
8 changes: 4 additions & 4 deletions src/drawing/polygons/polygon.ts
Expand Up @@ -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) {
Expand All @@ -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<google.maps.LatLng> =>
({}) as google.maps.MVCArray<google.maps.LatLng>
(): google.maps.MVCArray<google.maps.LatLng> => new MVCArray()
);
public getPaths = jest
.fn()
Expand All @@ -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 => {});
Expand Down
8 changes: 4 additions & 4 deletions src/drawing/polygons/polyline.ts
Expand Up @@ -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) {
Expand All @@ -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<google.maps.LatLng> =>
({}) as google.maps.MVCArray<google.maps.LatLng>
(): google.maps.MVCArray<google.maps.LatLng> => new MVCArray()
);
public getVisible = jest.fn().mockImplementation((): boolean => false);
public setDraggable = jest
Expand All @@ -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 => {});
Expand Down

0 comments on commit 3357752

Please sign in to comment.