Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"format": "eslint . --fix",
"lint": "eslint .",
"prepare": "rm -rf dist && rollup -c",
"test": "jest src/*"
"test": "jest src/*",
"test:watch": "jest --watch src/*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm test -- --watch would be equivalent

},
"devDependencies": {
"@rollup/plugin-typescript": "^8.3.0",
Expand Down
22 changes: 22 additions & 0 deletions src/data.feature.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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";

test("feature object is mocked", () => {
initialize();
expect(new google.maps.Data.Feature(null)).toBeTruthy();
});
59 changes: 59 additions & 0 deletions src/data.feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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.
*/

export class Feature implements google.maps.Data.Feature {
constructor(options?: google.maps.Data.FeatureOptions | null) {}
public forEachProperty = jest
.fn()
.mockImplementation((callback: (a: any, b: string) => void) => {
return null;
});
public getGeometry = jest.fn().mockImplementation(() => {
return null;
});
public getId = jest.fn().mockImplementation(() => {
return "1";
});
public getProperty = jest.fn().mockImplementation((name: string) => {
return undefined;
});
public removeProperty = jest.fn().mockImplementation((name: string) => {
return null;
});
public setGeometry = jest
.fn()
.mockImplementation(
(
newGeometry:
| google.maps.Data.Geometry
| null
| google.maps.LatLng
| google.maps.LatLngLiteral
) => {
return null;
}
);
public setProperty = jest
.fn()
.mockImplementation((name: string, newValue: any) => {
return null;
});
public toGeoJson = jest
.fn()
.mockImplementation((callback: (a: object) => void) => {
return null;
});
}
6 changes: 6 additions & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
* limitations under the License.
*/

import { Feature } from "./data.feature";
import { MVCObject } from "./mvcobject";

export class Data extends MVCObject implements google.maps.Data {
constructor(opt?: google.maps.Data.DataOptions | null) {
super();
}
public static Feature = jest
.fn()
.mockImplementation(
(options?: google.maps.Data.FeatureOptions | null) => new Feature(options)
);
public add = jest
.fn()
.mockImplementation(
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LatLng, LatLngBounds } from "./latlng";
import { Autocomplete } from "./places/autocomplete";
import { Circle } from "./circle";
import { Data } from "./data";
import { Feature } from "./data.feature";
import { MVCArray } from "./mvcarray";
import { MVCObject } from "./mvcobject";
import { MapCanvasProjection } from "./mapcanvasprojection";
Expand Down Expand Up @@ -83,6 +84,7 @@ export {
Marker,
Map_ as Map,
Data,
Feature,
Size,
MapCanvasProjection,
MapPanes,
Expand Down