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
6,174 changes: 3,043 additions & 3,131 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { StreetViewService } from "./street-view/service/service";
import { ControlPosition } from "./maps/controls/controlposition";
import { MapTypeId } from "./maps/maps/constants";
import { InfoWindow_ } from "./maps/infowindow/infowindow";
import { FeatureLayer } from "./maps/maps/featurelayer";
import { event } from "./maps/event/event";
import { mockInstances } from "./registry";

Expand Down Expand Up @@ -102,6 +103,7 @@ const initialize = function (): void {
MaxZoomService,
DirectionsService,
DistanceMatrixService,
FeatureLayer,
},
};
};
Expand Down Expand Up @@ -141,6 +143,7 @@ export {
MaxZoomService,
DirectionsService,
DistanceMatrixService,
FeatureLayer,
mockInstances,
initialize,
};
47 changes: 27 additions & 20 deletions src/maps/event/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const MapsEventListener: google.maps.MapsEventListener = {
remove: jest.fn(),
};

export const event: typeof google.maps.event = {
addDomListener: jest
export class event implements google.maps.event {
addDomListener = jest
.fn()
.mockImplementation(
(
Expand All @@ -28,8 +28,8 @@ export const event: typeof google.maps.event = {
handler: Function,
capture?: boolean
): google.maps.MapsEventListener => MapsEventListener
),
addDomListenerOnce: jest
);
addDomListenerOnce = jest
.fn()
.mockImplementation(
(
Expand All @@ -38,44 +38,51 @@ export const event: typeof google.maps.event = {
handler: Function,
capture?: boolean
): google.maps.MapsEventListener => MapsEventListener
),
addListener: jest
);

addListener = jest
.fn()
.mockImplementation(
(
instance: object,
eventName: string,
handler: Function
): google.maps.MapsEventListener => MapsEventListener
),
addListenerOnce: jest
);

addListenerOnce = jest
.fn()
.mockImplementation(
(
instance: object,
eventName: string,
handler: Function
): google.maps.MapsEventListener => MapsEventListener
),
clearInstanceListeners: jest
);

clearInstanceListeners = jest
.fn()
.mockImplementation((instance: object): void => null),
clearListeners: jest
.mockImplementation((instance: object): void => null);

clearListeners = jest
.fn()
.mockImplementation((instance: object, eventName: string): void => null),
hasListeners: jest
.mockImplementation((instance: object, eventName: string): void => null);

hasListeners = jest
.fn()
.mockImplementation(
(instance: object, eventName: string): boolean => false
),
removeListener: jest
);

removeListener = jest
.fn()
.mockImplementation(
(listener: google.maps.MapsEventListener): void => null
),
trigger: jest
);

trigger = jest
.fn()
.mockImplementation(
(instance: object, eventName: string, ...eventArgs: any[]): void => null
),
};
);
}
2 changes: 1 addition & 1 deletion src/maps/event/mvcobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MapsEventListener } from "./event";
/* eslint-disable @typescript-eslint/no-explicit-any */

export class MVCObject implements google.maps.MVCObject {
public static _mockClasses: typeof MVCObject[] = [];
public static _mockClasses: (typeof MVCObject)[] = [];
public static mockInstances: MVCObject[] = [];

public constructor() {
Expand Down
16 changes: 16 additions & 0 deletions src/maps/maps/featurelayer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MapsEventListener } from "../event/event";

export class FeatureLayer implements google.maps.FeatureLayer {
featureType: google.maps.FeatureType =
google.maps.FeatureType.ADMINISTRATIVE_AREA_LEVEL_1;
isAvailable = false;
style:
| google.maps.FeatureStyleOptions
| google.maps.FeatureStyleFunction
| null = null;

addListener = jest.fn(
(eventName: string, handler: Function): google.maps.MapsEventListener =>
MapsEventListener
);
}
36 changes: 23 additions & 13 deletions src/maps/maps/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import { StreetViewPanorama } from "../../street-view/rendering/panorama";
import { LatLng, LatLngBounds } from "../coordinates/latlng";
import { MVCObject } from "../event/mvcobject";
import { FeatureLayer } from "./featurelayer";

export class Map_ extends MVCObject implements google.maps.Map {
public controls: Array<google.maps.MVCArray<Node>>;
public controls: Array<google.maps.MVCArray<HTMLElement>>;
public data: google.maps.Data;
public mapTypes: google.maps.MapTypeRegistry;
public overlayMapTypes: google.maps.MVCArray<google.maps.MapType>;
Expand All @@ -28,18 +29,18 @@ export class Map_ extends MVCObject implements google.maps.Map {
super();
this.data = new google.maps.Data();
this.controls = [
new google.maps.MVCArray<Node>(), // BOTTOM_CENTER
new google.maps.MVCArray<Node>(), // BOTTOM_LEFT
new google.maps.MVCArray<Node>(), // BOTTOM_RIGHT
new google.maps.MVCArray<Node>(), // LEFT_BOTTOM
new google.maps.MVCArray<Node>(), // LEFT_CENTER
new google.maps.MVCArray<Node>(), // LEFT_TOP
new google.maps.MVCArray<Node>(), // RIGHT_BOTTOM
new google.maps.MVCArray<Node>(), // RIGHT_CENTER
new google.maps.MVCArray<Node>(), // RIGHT_TOP
new google.maps.MVCArray<Node>(), // TOP_CENTER
new google.maps.MVCArray<Node>(), // TOP_LEFT
new google.maps.MVCArray<Node>(), // TOP_RIGHT
new google.maps.MVCArray<HTMLElement>(), // BOTTOM_CENTER
new google.maps.MVCArray<HTMLElement>(), // BOTTOM_LEFT
new google.maps.MVCArray<HTMLElement>(), // BOTTOM_RIGHT
new google.maps.MVCArray<HTMLElement>(), // LEFT_BOTTOM
new google.maps.MVCArray<HTMLElement>(), // LEFT_CENTER
new google.maps.MVCArray<HTMLElement>(), // LEFT_TOP
new google.maps.MVCArray<HTMLElement>(), // RIGHT_BOTTOM
new google.maps.MVCArray<HTMLElement>(), // RIGHT_CENTER
new google.maps.MVCArray<HTMLElement>(), // RIGHT_TOP
new google.maps.MVCArray<HTMLElement>(), // TOP_CENTER
new google.maps.MVCArray<HTMLElement>(), // TOP_LEFT
new google.maps.MVCArray<HTMLElement>(), // TOP_RIGHT
];
this.mapTypes = new google.maps.MVCObject();
this.overlayMapTypes = new google.maps.MVCArray();
Expand Down Expand Up @@ -146,4 +147,13 @@ export class Map_ extends MVCObject implements google.maps.Map {
.mockImplementation((clickable: boolean): void => {
return null;
});
public getFeatureLayer = jest.fn(
(featureType: google.maps.FeatureType) => new FeatureLayer()
);
public getMapCapabilities = jest.fn(() => {
return {
isAdvancedMarkersAvailable: false,
isDataDrivenStylingAvailable: false,
};
});
}
1 change: 1 addition & 0 deletions src/street-view/rendering/panorama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ export class StreetViewPanorama
.fn()
.mockImplementation((flag: boolean): void => null);
public setZoom = jest.fn().mockImplementation((zoom: number): void => null);
public focus = jest.fn();
}