Skip to content

Instantly share code, notes, and snippets.

@merlosy
Created February 19, 2018 10:24
Show Gist options
  • Save merlosy/7c62c0c66404f74105bffa2ecaff5b8b to your computer and use it in GitHub Desktop.
Save merlosy/7c62c0c66404f74105bffa2ecaff5b8b to your computer and use it in GitHub Desktop.
Google Maps *Stubs* for Javascript API
/**
* This module aims to provides stubs Google Maps (Javascript API).
* It is not comprehensive, but a working solution that allows unit testing, without the async pain.
* @example
* import * as google from './google-maps.spec';
* (<any>window).google = google;
*/
export const google = {
maps: {
ControlPosition: {
TOP_LEFT: 1, TOP_CENTER: 2, TOP: 2, TOP_RIGHT: 3, LEFT_CENTER: 4, LEFT_TOP: 5,
LEFT: 5, LEFT_BOTTOM: 6, RIGHT_TOP: 7, RIGHT: 7, RIGHT_CENTER: 8,
RIGHT_BOTTOM: 9, BOTTOM_LEFT: 10, BOTTOM_CENTER: 11, BOTTOM: 11, BOTTOM_RIGHT: 12, CENTER: 13
},
event: {},
InfoWindow: class { },
LatLng: class { },
LatLngBounds: class { },
Map: class {
setZoom = () => { };
setCenter = () => { };
fitBounds = () => { };
},
MapTypeId: { ROADMAP: 'roadmap', SATELLITE: 'satellite', HYBRID: 'hybrid', TERRAIN: 'terrain' },
Marker: class { },
OverlayView: class { },
places: {
AutocompleteService: () => { },
PlacesService: (obj) => {
return {
PlacesServiceStatus: { OK: true },
textSearch: query => ([]),
nearbySearch: query => ([])
};
}
},
Symbol: class { },
SymbolPath: {
CIRCLE: 0, FORWARD_CLOSED_ARROW: 1, FORWARD_OPEN_ARROW: 2, BACKWARD_CLOSED_ARROW: 3, BACKWARD_OPEN_ARROW: 4
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment