Transition WorldMapCtrl tests
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/b82ec78f Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/b82ec78f Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/b82ec78f Branch: refs/heads/master Commit: b82ec78f7edea245aed7e153b1d2fb9db3c304b4 Parents: 81fed40 Author: Michael Joyce <[email protected]> Authored: Sun Jul 27 10:42:58 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Mon Aug 4 15:01:02 2014 -0700 ---------------------------------------------------------------------- .../test/spec/controllers/worldmap.js | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/b82ec78f/ocw-ui/frontend-new/test/spec/controllers/worldmap.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/test/spec/controllers/worldmap.js b/ocw-ui/frontend-new/test/spec/controllers/worldmap.js index 285d34a..76c702b 100644 --- a/ocw-ui/frontend-new/test/spec/controllers/worldmap.js +++ b/ocw-ui/frontend-new/test/spec/controllers/worldmap.js @@ -19,7 +19,7 @@ 'use strict'; -describe('Controller: WorldmapCtrl', function () { +describe('Controller: WorldMapCtrl', function () { // load the controller's module beforeEach(module('ocwUiApp')); @@ -30,12 +30,28 @@ describe('Controller: WorldmapCtrl', function () { // Initialize the controller and a mock scope beforeEach(inject(function ($controller, $rootScope) { scope = $rootScope.$new(); - WorldmapCtrl = $controller('WorldmapCtrl', { + WorldmapCtrl = $controller('WorldMapCtrl', { $scope: scope }); })); - it('should attach a list of awesomeThings to the scope', function () { - expect(scope.awesomeThings.length).toBe(3); + it('should initialize the updateMap function', function() { + inject(function($rootScope, $controller) { + var scope = $rootScope.$new(); + var ctrl = $controller("WorldMapCtrl", {$scope: scope}); + + // Set the important attributes for a fake dataset + scope.datasets.push({shouldDisplay: true, latlonVals: {latMin: 0, latMax: 0, lonMin: 0, lonMax: 0}}); + // Don't try to add the user defined region since we don't have one + scope.regionParams.areValid = false; + // We need to fake the map object. The only thing we care about is faking the "addLayer" function + // and the "fitBounds" functions which our map controllers makes use of. + $rootScope.map = {addLayer: function(){}, fitBounds: function(){}}; + $rootScope.fillColors = ['#ff0000']; + + expect("rectangleGroup" in $rootScope).toBe(false); + scope.updateMap(); + expect("rectangleGroup" in $rootScope).toBe(true); + }); }); });
