Skip to content

Instantly share code, notes, and snippets.

@stevehorn
Created March 8, 2012 16:01
Show Gist options
  • Save stevehorn/2001697 to your computer and use it in GitHub Desktop.
Save stevehorn/2001697 to your computer and use it in GitHub Desktop.
Spy Confusion
//Want to use this test setup
describe("Topography Controls", function () {
beforeEach(function () {
loadFixtures("NFocusMap.html");
this.dummyMap = new GoogleMapWrapper(null);
spyOn(this.dummyMap, 'addControlsRightTop');
spyOn(this.dummyMap, 'setOverlay');
this.classUnderTest = new ClassUnderTest(this.dummyMap);
});
});
var GoogleMapWrapper = function (map) {
var self = this;
self.map = map;
var initializeGoogleMap = function () {
//Throws because jquery is not defined
$.each(nmap.TileTypes, function (key, type) {
map.overlayMapTypes.push(null);
});
};
self.addControlsRightTop = function (controlsToAdd) {
map.controls[google.maps.ControlPosition.RIGHT_TOP].push(controlsToAdd);
};
self.setOverlay = function (imageMapTypeOptions, position) {
var carrierRouteImageMapType = new google.maps.ImageMapType(imageMapTypeOptions);
map.overlayMapTypes.setAt(position, carrierRouteImageMapType);
};
initializeGoogleMap();
};
//Hacked workaround
var GoogleMapWrapper = function (initialize, map) {
var self = this;
self.map = map;
var initializeGoogleMap = function () {
$.each(nmap.TileTypes, function (key, type) {
map.overlayMapTypes.push(null);
});
};
self.addControlsRightTop = function (controlsToAdd) {
map.controls[google.maps.ControlPosition.RIGHT_TOP].push(controlsToAdd);
};
self.setOverlay = function (imageMapTypeOptions, position) {
var carrierRouteImageMapType = new google.maps.ImageMapType(imageMapTypeOptions);
map.overlayMapTypes.setAt(position, carrierRouteImageMapType);
};
//Hack - only initialize if this isn't test mode:
if(initialize) {
initializeGoogleMap();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment