Skip to content

Instantly share code, notes, and snippets.

@rynbyjn
Created January 4, 2014 00:28
Show Gist options
  • Save rynbyjn/8249585 to your computer and use it in GitHub Desktop.
Save rynbyjn/8249585 to your computer and use it in GitHub Desktop.
Create spy objects for jasmine testing.
eventMethods = [
'Ga',
'Ke',
'Nj',
'Og',
'T',
'addDomListener',
'addDomListenerOnce',
'addListener',
'addListenerOnce',
'bind',
'clearInstanceListeners',
'clearListeners',
'forward',
'removeListener',
'trigger'
]
latLngMethods = [
'b',
'contains',
'equals',
'extend',
'getCenter',
'getNorthEast',
'getSouthWest',
'intersects',
'isEmpty',
'toSpan',
'toString',
'toUrlValue',
'union'
]
mapMethods = [
'M',
'constructor',
'fitBounds',
'getBounds',
'getCenter',
'getDiv',
'getHeading',
'getMapTypeId',
'getProjection',
'getStreetView',
'getTilt',
'getZoom',
'panBy',
'panTo',
'panToBounds',
'setCenter',
'setHeading',
'setMapTypeId',
'setStreetView',
'setTilt',
'setZoom',
'streetView_changed'
]
mapClasses = [
'BicyclingLayer',
'Circle',
'DirectionsRenderer',
'DirectionsService',
'DistanceMatrixService',
'ElevationService',
'FusionTablesLayer',
'Geocoder',
'GroundOverlay',
'ImageMapType',
'InfoWindow',
'KmlLayer',
'LatLng',
'MVCArray',
'MVCObject',
'MapTypeRegistry',
'Marker',
'MarkerImage',
'MaxZoomService',
'OverlayView',
'Point',
'Polygon',
'Polyline',
'Rectangle',
'Size',
'StreetViewPanorama',
'StreetViewService',
'StyledMapType',
'TrafficLayer',
'TransitLayer',
'__gjsload__'
]
mapObjects = [
'Animation',
'ControlPosition',
'DirectionsStatus',
'DirectionsTravelMode',
'DirectionsUnitSystem',
'DistanceMatrixElementStatus',
'DistanceMatrixStatus',
'ElevationStatus',
'GeocoderLocationType',
'GeocoderStatus',
'KmlLayerStatus',
'MapTypeControlStyle',
'MapTypeId',
'MaxZoomStatus',
'NavigationControlStyle',
'ScaleControlStyle',
'StreetViewStatus',
'SymbolPath',
'TravelMode',
'UnitSystem',
'ZoomControlStyle',
'geometry'
]
window.google =
maps:
event:
jasmine.createSpyObj('google.maps.event', eventMethods)
LatLngBounds: ->
jasmine.createSpyObj('google.maps.LatLngBounds', latLngMethods)
Map: ->
jasmine.createSpyObj('google.maps.Map', mapMethods)
# add other classes
_(google.maps).extend(jasmine.createSpyObj('google.maps', mapClasses))
# add objects
google.maps[object]={} for object in mapObjects
@simonmorley
Copy link

Helpfull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment