You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2013/06/18 20:50:24 UTC
svn commit: r1494254 -
/incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js
Author: joyce
Date: Tue Jun 18 18:50:24 2013
New Revision: 1494254
URL: http://svn.apache.org/r1494254
Log:
CLIMATE-123 progress - Add dataSelectUpdated test
Modified:
incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js
Modified: incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js?rev=1494254&r1=1494253&r2=1494254&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js (original)
+++ incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js Tue Jun 18 18:50:24 2013
@@ -82,5 +82,40 @@ describe('OCW Controllers', function() {
expect(scope.getObservationTimeRange(-1)).toEqual(false);
});
});
+
+ it('should initialize dataSelectUpdated function', function() {
+ inject(function($rootScope, $controller, $httpBackend) {
+ $rootScope.baseURL = "http://localhost:8082"
+ $httpBackend.expectJSONP($rootScope.baseURL + '/getObsDatasets?callback=JSON_CALLBACK').
+ respond(200, [{longname: 1}, {longname: 2}]);
+
+ var scope = $rootScope.$new();
+ var ctrl = $controller("RcmedSelectionCtrl", {$scope: scope});
+ $httpBackend.flush();
+
+ // Add the test dataset to our scope
+ scope.datasetSelection = {shortname: 'TRMM'}
+
+ // Test return with only single parameter
+ $httpBackend.expectJSONP($rootScope.baseURL + '/getDatasetParam?dataset=' +
+ scope.datasetSelection['shortname'] +
+ '&callback=JSON_CALLBACK').
+ respond(200, ['pcp']);
+ scope.dataSelectUpdated();
+ $httpBackend.flush();
+
+ expect(scope.parameterSelection).toEqual('pcp');
+
+ // Test return with multiple parameters
+ $httpBackend.expectJSONP($rootScope.baseURL + '/getDatasetParam?dataset=' +
+ scope.datasetSelection['shortname'] +
+ '&callback=JSON_CALLBACK').
+ respond(200, ['pcp', 'pcp2']);
+ scope.dataSelectUpdated();
+ $httpBackend.flush();
+
+ expect(scope.parameterSelection).toEqual({shortname: 'Please select a parameter'});
+ });
+ });
});
});