Skip to content

Commit 3357752

Browse files
authored
fix: polygon.getPath() should return an MVCArray (#572)
1 parent afe991e commit 3357752

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/drawing/polygons/polygon.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ test("getEditable returns false", () => {
3232
expect(new google.maps.Polygon(null).getEditable()).toBe(false);
3333
});
3434

35-
test("getMap returns {}", () => {
36-
expect(new google.maps.Polygon(null).getMap()).toEqual({});
35+
test("getMap returns null", () => {
36+
expect(new google.maps.Polygon(null).getMap()).toEqual(null);
3737
});
3838

39-
test("getPath returns {}", () => {
40-
expect(new google.maps.Polygon(null).getPath()).toEqual({});
39+
test("getPath returns an MVCArray", () => {
40+
const p = new google.maps.Polygon(null);
41+
const path = p.getPath();
42+
43+
expect(path).toBeInstanceOf(google.maps.MVCArray);
4144
});
4245

4346
test("getPaths returns {}", () => {

src/drawing/polygons/polygon.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { MVCObject } from "../../maps/event/mvcobject";
18+
import { MVCArray } from "../../maps/event/mvcarray";
1819

1920
export class Polygon extends MVCObject implements google.maps.Polygon {
2021
constructor(opts?: google.maps.PolygonOptions | null) {
@@ -25,12 +26,11 @@ export class Polygon extends MVCObject implements google.maps.Polygon {
2526
public getEditable = jest.fn().mockImplementation((): boolean => false);
2627
public getMap = jest
2728
.fn()
28-
.mockImplementation((): google.maps.Map => ({}) as google.maps.Map);
29+
.mockImplementation((): google.maps.Map | null => null);
2930
public getPath = jest
3031
.fn()
3132
.mockImplementation(
32-
(): google.maps.MVCArray<google.maps.LatLng> =>
33-
({}) as google.maps.MVCArray<google.maps.LatLng>
33+
(): google.maps.MVCArray<google.maps.LatLng> => new MVCArray()
3434
);
3535
public getPaths = jest
3636
.fn()
@@ -47,7 +47,7 @@ export class Polygon extends MVCObject implements google.maps.Polygon {
4747
.mockImplementation((editable: boolean): void => {});
4848
public setMap = jest
4949
.fn()
50-
.mockImplementation((map: google.maps.Map): void => {});
50+
.mockImplementation((map: google.maps.Map | null): void => {});
5151
public setOptions = jest
5252
.fn()
5353
.mockImplementation((options: google.maps.PolygonOptions): void => {});

src/drawing/polygons/polyline.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { MVCObject } from "../../maps/event/mvcobject";
18+
import { MVCArray } from "../../maps/event/mvcarray";
1819

1920
export class Polyline extends MVCObject implements google.maps.Polyline {
2021
constructor(opts?: google.maps.PolylineOptions | null) {
@@ -25,12 +26,11 @@ export class Polyline extends MVCObject implements google.maps.Polyline {
2526
public getEditable = jest.fn().mockImplementation((): boolean => false);
2627
public getMap = jest
2728
.fn()
28-
.mockImplementation((): google.maps.Map => ({}) as google.maps.Map);
29+
.mockImplementation((): google.maps.Map | null => null);
2930
public getPath = jest
3031
.fn()
3132
.mockImplementation(
32-
(): google.maps.MVCArray<google.maps.LatLng> =>
33-
({}) as google.maps.MVCArray<google.maps.LatLng>
33+
(): google.maps.MVCArray<google.maps.LatLng> => new MVCArray()
3434
);
3535
public getVisible = jest.fn().mockImplementation((): boolean => false);
3636
public setDraggable = jest
@@ -41,7 +41,7 @@ export class Polyline extends MVCObject implements google.maps.Polyline {
4141
.mockImplementation((editable: boolean): void => {});
4242
public setMap = jest
4343
.fn()
44-
.mockImplementation((map: google.maps.Map): void => {});
44+
.mockImplementation((map: google.maps.Map | null): void => {});
4545
public setOptions = jest
4646
.fn()
4747
.mockImplementation((options: google.maps.PolylineOptions): void => {});

0 commit comments

Comments
 (0)