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:27 UTC
svn commit: r1494255 -
/incubator/climate/trunk/rcmet/src/main/ui/test/unit/controllers/RcmedSelectionCtrlTest.js
Author: joyce
Date: Tue Jun 18 18:50:27 2013
New Revision: 1494255
URL: http://svn.apache.org/r1494255
Log:
Resolve CLIMATE-123 - Add tests for RcmedSelectionCtrl
- Add test for addObservation
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=1494255&r1=1494254&r2=1494255&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:27 2013
@@ -117,5 +117,45 @@ describe('OCW Controllers', function() {
expect(scope.parameterSelection).toEqual({shortname: 'Please select a parameter'});
});
});
+
+ it('should initialze the addObservation 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();
+
+ scope.datasetSelection = {
+ "dataset_id" : "3",
+ "shortname" : "TRMM",
+ "longname" : "Tropical Rainfall Measuring Mission Dataset",
+ "source" : "Readme for the Tropical Rainfall Measuring Mission (TRMM) Data Set"
+ };
+
+ scope.parameterSelection = {
+ "parameter_id":"36",
+ "shortname":"pcp",
+ "datasetshortname":"TRMM",
+ "longname":"TRMM v.6 Monthly Precipitation",
+ "units":"mm\/day"
+ };
+
+ // addObservations does a refresh of the selections with a re-query of the backend
+ // so we need to catch that call!
+ $httpBackend.expectJSONP($rootScope.baseURL + '/getObsDatasets?callback=JSON_CALLBACK').
+ respond(200, [{longname: 1}, {longname: 2}]);
+
+ scope.addObservation();
+ $httpBackend.flush();
+
+ expect(scope.datasetCount.length).toBe(1);
+ // The selection observation should be reset so we shouldn't have
+ // any selected observation parameters.
+ expect(scope.retrievedObsParams).toEqual([]);
+ });
+ });
});
});