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 2014/08/05 19:31:59 UTC

[01/19] git commit: Remove temporary test for ResultCtrl

Repository: climate
Updated Branches:
  refs/heads/master e34318319 -> e1a67b7f0


Remove temporary test for ResultCtrl


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/c1bc942c
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/c1bc942c
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/c1bc942c

Branch: refs/heads/master
Commit: c1bc942ce10eab238d9905edb2411d2fd148208d
Parents: 010da1e
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 19:17:46 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/spec/controllers/result.js | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/c1bc942c/ocw-ui/frontend-new/test/spec/controllers/result.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/result.js b/ocw-ui/frontend-new/test/spec/controllers/result.js
index 4fe372e..495a473 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/result.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/result.js
@@ -34,8 +34,4 @@ describe('Controller: ResultCtrl', function () {
       $scope: scope
     });
   }));
-
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
-  });
 });


[11/19] git commit: Remove temporary test for ResultDetailCtrl

Posted by jo...@apache.org.
Remove temporary test for ResultDetailCtrl


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/81fed40e
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/81fed40e
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/81fed40e

Branch: refs/heads/master
Commit: 81fed40ede2057456da41988415485d54240fbed
Parents: c1bc942
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 19:18:47 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/spec/controllers/resultdetail.js | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/81fed40e/ocw-ui/frontend-new/test/spec/controllers/resultdetail.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/resultdetail.js b/ocw-ui/frontend-new/test/spec/controllers/resultdetail.js
index 1d364f7..a29e508 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/resultdetail.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/resultdetail.js
@@ -34,8 +34,4 @@ describe('Controller: ResultdetailCtrl', function () {
       $scope: scope
     });
   }));
-
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
-  });
 });


[03/19] git commit: Initial ParameterSelectCtrl test update

Posted by jo...@apache.org.
Initial ParameterSelectCtrl test update


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/ab251b13
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/ab251b13
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/ab251b13

Branch: refs/heads/master
Commit: ab251b134986ffbbcd17746ea928307de38109f9
Parents: e45a3c2
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 18:50:51 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 .../test/spec/controllers/parameterselect.js    | 205 ++++++++++++++++++-
 1 file changed, 201 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/ab251b13/ocw-ui/frontend-new/test/spec/controllers/parameterselect.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/parameterselect.js b/ocw-ui/frontend-new/test/spec/controllers/parameterselect.js
index 4dcd886..e67b8df 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/parameterselect.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/parameterselect.js
@@ -19,7 +19,7 @@
 
 'use strict';
 
-describe('Controller: ParameterselectCtrl', function () {
+describe('Controller: ParameterSelectCtrl', function () {
 
   // load the controller's module
   beforeEach(module('ocwUiApp'));
@@ -30,12 +30,209 @@ describe('Controller: ParameterselectCtrl', function () {
   // Initialize the controller and a mock scope
   beforeEach(inject(function ($controller, $rootScope) {
     scope = $rootScope.$new();
-    ParameterselectCtrl = $controller('ParameterselectCtrl', {
+    ParameterselectCtrl = $controller('ParameterSelectCtrl', {
       $scope: scope
     });
   }));
 
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
+  it('should initialize spatial and temporal range default values properly', function() {
+    expect(scope.latMin).toBe(-90);
+    expect(scope.latMax).toBe(90);
+    expect(scope.lonMin).toBe(-180);
+    expect(scope.lonMax).toBe(180);
+    expect(scope.start).toBe("1900-01-01 00:00:00");
+    expect(scope.end).toBe("2030-01-01 00:00:00");
   });
+
+  it('should grab the default set of selected datasets from the service', function() {
+    // We should get an object with no keys since the user hasn't selected any
+    // datasets by default. Object.keys returns an array of all the user defined
+    // keys in the object.
+    expect(typeof scope.datasets).toBe('object');
+    expect(Object.keys(scope.datasets).length).toBe(0);
+  });
+
+  it('should grab the default region select param object from the regionSelectParams service', function() {
+    // The default display values aren't going to be changing any time soon. This test 
+    // is a bit of a duplicate since this is really testing functionality of the service.
+    // Can't hurt to make sure that we're getting results though!
+    expect(typeof scope.displayParams).toBe('object');
+    expect(Object.keys(scope.displayParams).length).toBe(7);
+  });
+
+  it('should initialize misc. values properly', function() {
+    expect(scope.runningEval).toBe(false);
+    expect(scope.areInUserRegridState).toBe(false);
+    expect(scope.latSliderVal).toBe(0);
+    expect(scope.lonSliderVal).toBe(0);
+  });
+
+  it('should set the default datepicker settings', function() {
+    // This tests the default values that get passed to the datepicker objects that we
+    // initialize with a directive.
+    expect(Object.keys(scope.datepickerSettings).length).toBe(2);
+    expect(scope.datepickerSettings.changeMonth).toBe(true);
+    expect(scope.datepickerSettings.changeYear).toBe(true);
+  });
+
+  it('should initialize the control disable function', function() {
+    // Add to dummy values to datasets to make sure the disable function
+    // triggers properly.
+    scope.datasets.push(1);
+    scope.datasets.push(2);
+    expect(scope.shouldDisableControls()).toBe(false);
+  });
+
+  it('should initialize the disable evaluation button function', function() {
+    expect(scope.shouldDisableEvaluateButton()).toBe(true);
+    scope.datasets.push(1);
+    expect(scope.shouldDisableEvaluateButton()).toBe(true);
+    scope.datasets.push(2);
+    expect(scope.shouldDisableEvaluateButton()).toBe(false);
+    scope.runningEval = true;
+    expect(scope.shouldDisableEvaluateButton()).toBe(true);
+  });
+
+  it('should initialize the disable results view function', function() {
+    inject(function($rootScope) {
+      expect(scope.shouldDisableResultsView()).toBe(true);
+
+      // Set evalResults to something other than the default value
+      $rootScope.evalResults = "this is not an empty string";
+
+      expect(scope.shouldDisableResultsView()).toBe(false);
+    });
+  });
+
+  /*
+   * TODO: $scope.$apply() in the controller is breaking this test. Need to
+   * find a way to deal with that or rethink how we handle this test.
+   *
+   */
+  /*
+  it('should initialize the check parameters function', function() {
+      // Set the displayParams values to be "out of bounds" values so checkParams 
+      // adjusts them properly.
+      scope.displayParams.latMin = "-95";
+      scope.displayParams.latMax = "95";
+      scope.displayParams.lonMin = "-185";
+      scope.displayParams.lonMax = "185";
+      scope.displayParams.start = "1980-00-00 00:00:00";
+      scope.displayParams.end = "2031-01-01 00:00:00";
+
+      // If we don't remove the watch on datasets we end up with displayParam values 
+      // all being undefined (but only during testing, which is odd...)
+      scope.unwatchDatasets();
+      scope.checkParameters();
+
+      expect(scope.displayParams.latMin).toBe(-90);
+      expect(scope.displayParams.latMax).toBe(90);
+      expect(scope.displayParams.lonMin).toBe(-180);
+      expect(scope.displayParams.lonMax).toBe(180);
+      expect(scope.displayParams.start).toBe('1980-01-01 00:00:00');
+      expect(scope.displayParams.end).toBe('2030-01-01 00:00:00');
+  });
+  */
+
+  /*
+   * TODO: The backend call for this expects completely different data formats.
+   * Additionally, there are many more URLs to mock now. Something has definitely
+   * changed with how httpBackend functions or the way the code base is setup.
+   */
+  /*
+  it('should properly set the results of running an evaluation', function() {
+    inject(function($rootScope, $controller, $httpBackend) {
+      var scope = $rootScope.$new();
+      var ctrl = $controller("ParameterSelectCtrl", {$scope: scope});
+
+      // Seed rootScope with a known URL for test queries and holder for eval results
+      $rootScope.baseURL = "http://localhost:9876";
+      $rootScope.evalResults = {};
+
+      // Seed the displayParams so the query is properly formatted
+      scope.displayParams.lonMin = -180;
+      scope.displayParams.lonMax = 180;
+      scope.displayParams.latMin = -90;
+      scope.displayParams.latMax = 90;
+      scope.displayParams.start = "1980-01-01";
+      scope.displayParams.end = "2030-01-01";
+
+      // The expected URL string that the frontend generates given this example set
+      var urlString = "http://localhost:9876/rcmes/run/?" + 
+        "callback=JSON_CALLBACK&" + 
+        "endTime=2030-01-01%2000%3A00%3A00&" +
+        "filelist=%2Fusr%2Flocal%2Frcmes%2FmodelsForUI%2Fprec.HRM3.ncep.monavg.nc&" +
+        "latMax=90&" +
+        "latMin=-90&" +
+        "lonMax=180&" +
+        "lonMin=-180&" +
+        "metricOption=bias&" +
+        "modelLatVarName=lat&" +
+        "modelLonVarName=lon&" +
+        "modelTimeVarName=time&" +
+        "modelVarName=prec&" +
+        "obsDatasetId=3&" +
+        "obsParameterId=36&" +
+        "regridOption=model&" +
+        "startTime=1980-01-01%2000%3A00%3A00&" +
+        "timeRegridOption=monthly";
+
+      // Example dataset configuration for the test.
+      scope.datasets = [
+        {
+          "isObs"         : 1,
+          "id"            : "3",
+          "name"          : "Tropical Rainfall Measuring Mission Dataset",
+          "param"         : "36",
+          "paramName"     : "TRMM v.6 Monthly Precipitation",
+          "latlonVals"    : {"latMin" : -90, "latMax" : 90, "lonMin" : -180, "lonMax" : 180},
+          "lat"           : "N/A",
+          "lon"           : "N/A",
+          "timeVals"      : {"start" : "1998-01-01 00:00:00",
+          "end"           : "2010-01-01 00:00:00"},
+          "time"          : "N/A",
+          "shouldDisplay" : true,
+          "regrid"        : false
+          },{
+          "isObs"         : 0,
+          "id"            : "/usr/local/rcmes/modelsForUI/prec.HRM3.ncep.monavg.nc",
+          "name"          : "prec.HRM3.ncep.monavg.nc",
+          "param"         : "prec",
+          "paramName"     : "prec",
+          "lat"           : "lat",
+          "lon"           : "lon",
+          "latlonVals"    : {"latMin" : "15.25",
+          "latMax"        : "75.25",
+          "lonMin"        : "-159.75",
+          "lonMax"        : "-29.75"},
+          "time"          : "time",
+          "timeVals"      : {"start":"1980-01-01 00:00:00",
+          "end"           : "2004-12-01 00:00:00"},
+          "shouldDisplay" : true,
+          "regrid"        : false
+        }
+      ];
+
+      $httpBackend.expectGET('http://localhost:8082/processing/metrics/').respond(
+        200, {'data': {'metrics': ['foo', 'bar']}}
+      )
+      $httpBackend.expectPOST('http://localhost:9876/processing/run_evaluation/').respond(200) 
+      $httpBackend.expectGET('views/main.html').respond(200)
+      $httpBackend.expectJSONP(urlString).respond(200, 
+          {'comparisonPath': '/fake/path1', 
+           'modelPath': '/fake/path2', 
+           'obsPath': '/fake/path3'});
+
+      console.log('here')
+      scope.runEvaluation();
+      console.log('here1')
+      $httpBackend.flush();
+      console.log('here2')
+
+      expect($rootScope.evalResults.comparisonPath).toBe('path1');
+      expect($rootScope.evalResults.modelPath).toBe('path2');
+      expect($rootScope.evalResults.obsPath).toBe('path3');
+    });
+  });
+  */
 });


[17/19] git commit: Transition regionselectparams service tests

Posted by jo...@apache.org.
Transition regionselectparams service tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/459154f4
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/459154f4
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/459154f4

Branch: refs/heads/master
Commit: 459154f4736180a0bf9554e52f317be5d43e2bc4
Parents: 94daf20
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:52:34 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 .../test/spec/services/regionselectparams.js             | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/459154f4/ocw-ui/frontend-new/test/spec/services/regionselectparams.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/services/regionselectparams.js b/ocw-ui/frontend-new/test/spec/services/regionselectparams.js
index 2ad9dab..34cfe54 100644
--- a/ocw-ui/frontend-new/test/spec/services/regionselectparams.js
+++ b/ocw-ui/frontend-new/test/spec/services/regionselectparams.js
@@ -30,8 +30,15 @@ describe('Service: regionSelectParams', function () {
     regionSelectParams = _regionSelectParams_;
   }));
 
-  it('should do something', function () {
-    expect(!!regionSelectParams).toBe(true);
+  it('should initialize the regionSelectParams service', function() {
+    inject(function(regionSelectParams) {
+      expect(regionSelectParams).not.toEqual(null);
+    });
   });
 
+  it('should provide the getParameters function', function() {
+    inject(function(regionSelectParams) {
+      expect(regionSelectParams.getParameters()).not.toEqual(null);
+    });
+  });
 });


[02/19] git commit: Transition RcmedSelectCtrl tests

Posted by jo...@apache.org.
Transition RcmedSelectCtrl tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/010da1e4
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/010da1e4
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/010da1e4

Branch: refs/heads/master
Commit: 010da1e45dfea1144fad85eee80e11f99600c18c
Parents: ab251b1
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 19:12:29 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 .../test/spec/controllers/rcmedselection.js     | 112 ++++++++++++++++++-
 1 file changed, 108 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/010da1e4/ocw-ui/frontend-new/test/spec/controllers/rcmedselection.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/rcmedselection.js b/ocw-ui/frontend-new/test/spec/controllers/rcmedselection.js
index 0466e84..97011c7 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/rcmedselection.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/rcmedselection.js
@@ -19,7 +19,7 @@
 
 'use strict';
 
-describe('Controller: RcmedselectionCtrl', function () {
+describe('Controller: RcmedSelectionCtrl', function () {
 
   // load the controller's module
   beforeEach(module('ocwUiApp'));
@@ -30,12 +30,116 @@ describe('Controller: RcmedselectionCtrl', function () {
   // Initialize the controller and a mock scope
   beforeEach(inject(function ($controller, $rootScope) {
     scope = $rootScope.$new();
-    RcmedselectionCtrl = $controller('RcmedselectionCtrl', {
+    RcmedselectionCtrl = $controller('RcmedSelectionCtrl', {
       $scope: scope
     });
   }));
 
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
+  it('should automatically query RCMED on initialization', function() {
+    inject(function($rootScope, $httpBackend) {
+      $httpBackend.expectJSONP($rootScope.baseURL + '/rcmed/datasets/?callback=JSON_CALLBACK').
+        respond(200, [{longname: 1}, {longname: 2}]);
+      $httpBackend.expectGET($rootScope.baseURL + '/rcmed/parameters/bounds/').respond(503)
+      $httpBackend.expectGET('views/main.html').respond(200);
+      $httpBackend.flush();
+
+      expect(scope.availableObs.length).toBe(3);
+      expect(scope.availableObs[0]).toEqual({longname: "Please select an option"});
+      expect(scope.availableObs[1]).toEqual({longname: 1});
+    });
+  });
+
+  it('should initialize the getObservations function', function() {
+    inject(function($rootScope, $httpBackend) {
+      $httpBackend.expectJSONP($rootScope.baseURL + '/rcmed/datasets/?callback=JSON_CALLBACK').
+        respond(200, [{longname: 1}, {longname: 2}]);
+      $httpBackend.expectGET($rootScope.baseURL + '/rcmed/parameters/bounds/').respond(503)
+      $httpBackend.expectGET('views/main.html').respond(200);
+      $httpBackend.flush();
+
+      expect(scope.availableObs.length).toBe(3);
+      expect(scope.availableObs[0]).toEqual({longname: "Please select an option"});
+      expect(scope.availableObs[1]).toEqual({longname: 1});
+
+      // Set up a failed query
+      $httpBackend.expectJSONP($rootScope.baseURL + '/rcmed/datasets/?callback=JSON_CALLBACK').
+        respond(404);
+      scope.getObservations();
+      $httpBackend.flush();
+
+      expect(scope.availableObs.length).toBe(1);
+      expect(scope.availableObs[0]).toEqual('Unable to query RCMED');
+    });
+  });
+
+  it('should initialize dataSelectUpdated function', function() {
+    inject(function($rootScope, $controller, $httpBackend) {
+      $httpBackend.expectJSONP($rootScope.baseURL + '/rcmed/datasets/?callback=JSON_CALLBACK').
+        respond(200, [{longname: 1}, {longname: 2}]);
+      $httpBackend.expectGET($rootScope.baseURL + '/rcmed/parameters/bounds/').respond(503)
+      $httpBackend.expectGET('views/main.html').respond(200);
+      $httpBackend.flush();
+
+      // Add the test dataset to our scope
+      scope.datasetSelection = {shortname: 'TRMM'}
+
+      // Test return with only single parameter
+      $httpBackend.expectJSONP($rootScope.baseURL + '/rcmed/parameters/?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 + '/rcmed/parameters/?dataset=' +
+                  scope.datasetSelection['shortname'] +
+                  '&callback=JSON_CALLBACK').
+             respond(200, ['pcp', 'pcp2']);
+      scope.dataSelectUpdated();
+      $httpBackend.flush();
+
+      expect(scope.parameterSelection).toEqual({shortname: 'Please select a parameter'});
+    });
+  });
+
+  it('should initialze the addObservation function', function() {
+    inject(function($rootScope, $controller, $httpBackend) {
+      $httpBackend.expectJSONP($rootScope.baseURL + '/rcmed/datasets/?callback=JSON_CALLBACK').
+        respond(200, [{longname: 1}, {longname: 2}]);
+      $httpBackend.expectGET($rootScope.baseURL + '/rcmed/parameters/bounds/').respond(503)
+      $httpBackend.expectGET('views/main.html').respond(200);
+      $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 + '/rcmed/datasets/?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([]);
+    });
   });
 });


[06/19] git commit: Transition DatasetSelectCtrl Tests

Posted by jo...@apache.org.
Transition DatasetSelectCtrl Tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/a624cecd
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/a624cecd
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/a624cecd

Branch: refs/heads/master
Commit: a624cecde227aeb8fc29ca1aa21dbae29f4a5227
Parents: 663e5bd
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 16:44:58 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 .../test/spec/controllers/datasetselect.js      | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/a624cecd/ocw-ui/frontend-new/test/spec/controllers/datasetselect.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/datasetselect.js b/ocw-ui/frontend-new/test/spec/controllers/datasetselect.js
index 50267b6..abaeb43 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/datasetselect.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/datasetselect.js
@@ -19,7 +19,7 @@
 
 'use strict';
 
-describe('Controller: DatasetselectCtrl', function () {
+describe('Controller: DatasetSelectCtrl', function () {
 
   // load the controller's module
   beforeEach(module('ocwUiApp'));
@@ -30,12 +30,25 @@ describe('Controller: DatasetselectCtrl', function () {
   // Initialize the controller and a mock scope
   beforeEach(inject(function ($controller, $rootScope) {
     scope = $rootScope.$new();
-    DatasetselectCtrl = $controller('DatasetselectCtrl', {
+    DatasetselectCtrl = $controller('DatasetSelectCtrl', {
       $scope: scope
     });
   }));
 
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
+  it('should initialize the disable clear button function', function() {
+    inject(function(selectedDatasetInformation) {
+      expect(scope.shouldDisableClearButton()).toBe(true);
+      selectedDatasetInformation.addDataset({});
+      expect(scope.shouldDisableClearButton()).toBe(false);
+    });
+  });
+
+  it('should initialize the clear datasets function', function() {
+    inject(function(selectedDatasetInformation) {
+      selectedDatasetInformation.addDataset({});
+      expect(selectedDatasetInformation.getDatasetCount()).toBe(1);
+      scope.clearDatasets();
+      expect(selectedDatasetInformation.getDatasetCount()).toBe(0);
+    });
   });
 });


[16/19] git commit: Transition evaluationsettings service tests

Posted by jo...@apache.org.
Transition evaluationsettings service tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/94daf209
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/94daf209
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/94daf209

Branch: refs/heads/master
Commit: 94daf209ab122e13aa4ec1055023cf9debddadcd
Parents: bce574b
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:52:16 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 .../test/spec/services/evaluationsettings.js             | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/94daf209/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js b/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js
index 8fb20c2..01fa63b 100644
--- a/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js
+++ b/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js
@@ -30,8 +30,15 @@ describe('Service: evaluationSettings', function () {
     evaluationSettings = _evaluationSettings_;
   }));
 
-  it('should do something', function () {
-    expect(!!evaluationSettings).toBe(true);
+  it('should initialize the evaluationSettings service', function() {
+    inject(function(evaluationSettings) {
+      expect(evaluationSettings).not.toEqual(null);
+    });
   });
 
+  it('should provide a getSettings function', function() {
+    inject(function(evaluationSettings) {
+      expect(evaluationSettings.getSettings()).not.toEqual(null);
+    })
+  })
 });


[05/19] git commit: Initial ObservationSelectCtrl test migration

Posted by jo...@apache.org.
Initial ObservationSelectCtrl test migration


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/e45a3c23
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/e45a3c23
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/e45a3c23

Branch: refs/heads/master
Commit: e45a3c23a5a2487aa451c4a997558892f1645c67
Parents: a624cec
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 18:09:11 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 .../test/spec/controllers/observationselect.js  | 98 +++++++++++++++++++-
 1 file changed, 94 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/e45a3c23/ocw-ui/frontend-new/test/spec/controllers/observationselect.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/observationselect.js b/ocw-ui/frontend-new/test/spec/controllers/observationselect.js
index 81a194f..7490144 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/observationselect.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/observationselect.js
@@ -19,7 +19,7 @@
 
 'use strict';
 
-describe('Controller: ObservationselectCtrl', function () {
+describe('Controller: ObservationSelectCtrl', function () {
 
   // load the controller's module
   beforeEach(module('ocwUiApp'));
@@ -30,12 +30,102 @@ describe('Controller: ObservationselectCtrl', function () {
   // Initialize the controller and a mock scope
   beforeEach(inject(function ($controller, $rootScope) {
     scope = $rootScope.$new();
-    ObservationselectCtrl = $controller('ObservationselectCtrl', {
+    ObservationselectCtrl = $controller('ObservationSelectCtrl', {
       $scope: scope
     });
   }));
 
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
+  it('should grab the default set of selected datasets from the service', function() {
+    expect(typeof scope.datasetCount).toBe('object');
+    expect(Object.keys(scope.datasetCount).length).toBe(0);
+  });
+
+  it('should initialize option arrays and default to the first element', function() {
+    expect(scope.params.length).toBe(1);
+    expect(scope.lats.length).toBe(1);
+    expect(scope.lons.length).toBe(1);
+    expect(scope.times.length).toBe(1);
+
+    expect(scope.params[0]).toEqual("Please select a file above");
+    expect(scope.lats[0]).toEqual("Please select a file above");
+    expect(scope.lons[0]).toEqual("Please select a file above");
+    expect(scope.times[0]).toEqual("Please select a file above");
+  });
+
+  /*
+  it('should initialize scope attributes properly', function() {
+    inject(function($httpBackend, $rootScope, $controller) {
+      $rootScope.baseURL = "http://localhost:8082"
+      $httpBackend.expectJSONP($rootScope.baseURL + '/getPathLeader/?callback=JSON_CALLBACK').
+        respond(200, {'leader': '/usr/local/rcmes'});
+
+      var scope = $rootScope.$new();
+      var ctrl = $controller("ObservationSelectCtrl", {$scope: scope});
+      $httpBackend.flush();
+
+      expect(scope.pathLeader).toEqual('/usr/local/rcmes');
+      expect(scope.loadingFile).toBe(false);
+      expect(scope.fileAdded).toBe(false);
+      expect(typeof scope.latLonVals).toEqual('object');
+      expect(scope.latLonVals.length).toBe(0);
+      expect(typeof scope.timeVals).toEqual('object');
+      expect(scope.timeVals.length).toEqual(0);
+      expect(typeof scope.localSelectForm).toEqual('object');
+      expect(Object.keys(scope.localSelectForm).length).toEqual(0);
+    });
+  });
+  */
+
+  /*
+  it('should initialize the uploadLocalFile function', function() {
+    inject(function($httpBackend, $rootScope, $controller) {
+      $rootScope.baseURL = "http://localhost:8082"
+      $httpBackend.expectJSONP($rootScope.baseURL + '/dir/path_leader/?callback=JSON_CALLBACK').
+        respond(200, {'leader': '/usr/local/rcmes'});
+
+      var scope = $rootScope.$new();
+      var ctrl = $controller("ObservationSelectCtrl", {$scope: scope});
+      $httpBackend.flush();
+
+      $httpBackend.expectJSONP($rootScope.baseURL + '/list/vars/"/usr/local/rcmesundefined"?callback=JSON_CALLBACK').
+        respond(200, {"variables": ["lat", "lon", "prec", "time" ]});
+      $httpBackend.expectJSONP($rootScope.baseURL + '/list/latlon/"/usr/local/rcmesundefined"?callback=JSON_CALLBACK').
+        respond(200, {'latMax': '75.25', 'success': 1, 'latname': 'lat', 'lonMax': '-29.75', 'lonMin': '-159.75', 'lonname': 'lon', 'latMin': '15.25'});
+      $httpBackend.expectJSONP($rootScope.baseURL + '/list/time/"/usr/local/rcmesundefined"?callback=JSON_CALLBACK').
+        respond(200, {"start_time": "1980-01-01 00:00:00", "timename": "time", "success": 1, "end_time": "2004-12-01 00:00:00"});
+
+      scope.uploadLocalFile();
+      $httpBackend.flush();
+
+      expect(scope.latsSelect).toEqual("lat");
+      expect(scope.lonsSelect).toEqual("lon");
+      expect(scope.timeSelect).toEqual("time");
+      expect(scope.paramSelect).toEqual("prec");
+
+      // Simulate failure on one of the backend calls. Should
+      $httpBackend.expectJSONP($rootScope.baseURL + '/list/vars/"/usr/local/rcmesundefined"?callback=JSON_CALLBACK').
+        respond(200, {});
+      $httpBackend.expectJSONP($rootScope.baseURL + '/list/latlon/"/usr/local/rcmesundefined"?callback=JSON_CALLBACK').
+        respond(404, {});
+      $httpBackend.expectJSONP($rootScope.baseURL + '/list/time/"/usr/local/rcmesundefined"?callback=JSON_CALLBACK').
+        respond(200, {});
+
+      scope.uploadLocalFile();
+      $httpBackend.flush();
+
+      expect(scope.paramSelect).toEqual("Unable to load variable(s)");
+      expect(scope.params.length).toEqual(1);
+      expect(scope.latsSelect).toEqual("Unable to load variable(s)");
+      expect(scope.lats.length).toEqual(1);
+      expect(scope.lonsSelect).toEqual("Unable to load variable(s)");
+      expect(scope.lons.length).toEqual(1);
+      expect(scope.timeSelect).toEqual("Unable to load variable(s)");
+      expect(scope.times.length).toEqual(1);
+    });
+  });
+  */
+
+  it('should initialize the addDatasets function', function() {
+    expect(typeof(scope.addDataSet)).toBe("function");
   });
 });


[04/19] git commit: Fix karam conf for unit test transition.

Posted by jo...@apache.org.
Fix karam conf for unit test transition.


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/5a6db3f0
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/5a6db3f0
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/5a6db3f0

Branch: refs/heads/master
Commit: 5a6db3f0ef7b35b5b07061e58aa1a86f60f12477
Parents: e343183
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 12:06:06 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/karma.conf.js | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/5a6db3f0/ocw-ui/frontend-new/test/karma.conf.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/karma.conf.js b/ocw-ui/frontend-new/test/karma.conf.js
index eb62e55..a552aa6 100644
--- a/ocw-ui/frontend-new/test/karma.conf.js
+++ b/ocw-ui/frontend-new/test/karma.conf.js
@@ -24,6 +24,15 @@ module.exports = function(config) {
       'bower_components/angular-cookies/angular-cookies.js',
       'bower_components/angular-resource/angular-resource.js',
       'bower_components/angular-route/angular-route.js',
+      'bower_components/angular-animate/angular-animate.js',
+      'bower_components/angular-bootstrap/ui-bootstrap.js',
+      'bower_components/angular-scenario/angular-scenario.js',
+      'bower_components/angular-ui-date/src/date.js',
+      'bower_components/angular-ui-router/release/angular-ui-router.js',
+      'bower_components/chap-links-timeline/timeline.js',
+      'bower_components/jquery/dist/jquery.js',
+      'bower_components/jquery-ui/jquery-ui.js',
+      'bower_components/leaflet/dist/leaflet.js',
       'app/scripts/**/*.js',
       'test/mock/**/*.js',
       'test/spec/**/*.js'


[18/19] git commit: Transition WorldMapCtrl tests

Posted by jo...@apache.org.
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 <jo...@apache.org>
Authored: Sun Jul 27 10:42:58 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
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);
+    });
   });
 });


[13/19] git commit: Transition onblur tests

Posted by jo...@apache.org.
Transition onblur tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/ce9715b3
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/ce9715b3
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/ce9715b3

Branch: refs/heads/master
Commit: ce9715b3b190928e534092df790b5353b7d21ea8
Parents: b82ec78
Author: Michael Joyce <jo...@apache.org>
Authored: Sun Jul 27 10:53:52 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 .../frontend-new/test/spec/directives/onblur.js | 21 +++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/ce9715b3/ocw-ui/frontend-new/test/spec/directives/onblur.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/onblur.js b/ocw-ui/frontend-new/test/spec/directives/onblur.js
index bc1c49d..7e8b83a 100644
--- a/ocw-ui/frontend-new/test/spec/directives/onblur.js
+++ b/ocw-ui/frontend-new/test/spec/directives/onblur.js
@@ -31,9 +31,20 @@ describe('Directive: onBlur', function () {
     scope = $rootScope.$new();
   }));
 
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<on-blur></on-blur>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the onBlur directive');
-  }));
+  it('should call the supplied function on the blur event', function() {
+    inject(function($compile) {
+      // Set a scope variable to make sure that on-blur calls 
+      // the function that we pass to it.
+      scope.bogusFunction = function() {
+        scope.test = "hi"
+      }
+
+      var element = angular.element('<input on-blur="bogusFunction();" />')
+      element = $compile(element)(scope)
+
+      expect(scope.test).toNotBe('hi');
+      element.triggerHandler('blur');
+      expect(scope.test).toBe('hi');
+    });
+  });
 });


[08/19] git commit: Fix broken karma config import and adjust default browsers

Posted by jo...@apache.org.
Fix broken karma config import and adjust default browsers

- An angular-scenario import was causing all tests to fail if it is
  left uncommented.
- Add Chrome browser option and plugin to config but keep PhantomJS as
  the default.


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/819acb7d
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/819acb7d
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/819acb7d

Branch: refs/heads/master
Commit: 819acb7d6f002a0bda228ac21542dcdd34b32782
Parents: c169157
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 14:00:35 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/karma.conf.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/819acb7d/ocw-ui/frontend-new/test/karma.conf.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/karma.conf.js b/ocw-ui/frontend-new/test/karma.conf.js
index a552aa6..744d927 100644
--- a/ocw-ui/frontend-new/test/karma.conf.js
+++ b/ocw-ui/frontend-new/test/karma.conf.js
@@ -26,7 +26,9 @@ module.exports = function(config) {
       'bower_components/angular-route/angular-route.js',
       'bower_components/angular-animate/angular-animate.js',
       'bower_components/angular-bootstrap/ui-bootstrap.js',
-      'bower_components/angular-scenario/angular-scenario.js',
+      // For some reason this causes the tests to completely fail to run
+      // if it is uncommented.
+      //'bower_components/angular-scenario/angular-scenario.js',
       'bower_components/angular-ui-date/src/date.js',
       'bower_components/angular-ui-router/release/angular-ui-router.js',
       'bower_components/chap-links-timeline/timeline.js',
@@ -53,12 +55,14 @@ module.exports = function(config) {
     // - PhantomJS
     // - IE (only Windows)
     browsers: [
-      'PhantomJS'
+      'PhantomJS',
+      //'Chrome'
     ],
 
     // Which plugins to enable
     plugins: [
       'karma-phantomjs-launcher',
+      'karma-chrome-launcher',
       'karma-jasmine'
     ],
 


[12/19] git commit: Remove placeholder controller tests

Posted by jo...@apache.org.
Remove placeholder controller tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/e092e0f5
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/e092e0f5
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/e092e0f5

Branch: refs/heads/master
Commit: e092e0f5c1c967ee90c5788d9abc3796c476f2d7
Parents: af34aaa
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:46:07 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/spec/controllers/settings.js | 4 ----
 ocw-ui/frontend-new/test/spec/controllers/timeline.js | 4 ----
 2 files changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/e092e0f5/ocw-ui/frontend-new/test/spec/controllers/settings.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/settings.js b/ocw-ui/frontend-new/test/spec/controllers/settings.js
index b566d5c..e45accd 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/settings.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/settings.js
@@ -34,8 +34,4 @@ describe('Controller: SettingsCtrl', function () {
       $scope: scope
     });
   }));
-
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
-  });
 });

http://git-wip-us.apache.org/repos/asf/climate/blob/e092e0f5/ocw-ui/frontend-new/test/spec/controllers/timeline.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/timeline.js b/ocw-ui/frontend-new/test/spec/controllers/timeline.js
index 2a2d524..1f3580f 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/timeline.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/timeline.js
@@ -34,8 +34,4 @@ describe('Controller: TimelineCtrl', function () {
       $scope: scope
     });
   }));
-
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
-  });
 });


[07/19] git commit: Transition DatasetDisplayCtrl tests

Posted by jo...@apache.org.
Transition DatasetDisplayCtrl tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/663e5bd6
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/663e5bd6
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/663e5bd6

Branch: refs/heads/master
Commit: 663e5bd6977ea1106c535ad4a7ac8066d3fc1ae3
Parents: 5a6db3f
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Jul 25 16:29:28 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:01 2014 -0700

----------------------------------------------------------------------
 .../test/spec/controllers/datasetdisplay.js     | 28 ++++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/663e5bd6/ocw-ui/frontend-new/test/spec/controllers/datasetdisplay.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/controllers/datasetdisplay.js b/ocw-ui/frontend-new/test/spec/controllers/datasetdisplay.js
index 75d0927..15a4a02 100644
--- a/ocw-ui/frontend-new/test/spec/controllers/datasetdisplay.js
+++ b/ocw-ui/frontend-new/test/spec/controllers/datasetdisplay.js
@@ -19,23 +19,41 @@
 
 'use strict';
 
-describe('Controller: DatasetdisplayctrlCtrl', function () {
+describe('Controller: DatasetDisplayCtrl', function () {
 
   // load the controller's module
   beforeEach(module('ocwUiApp'));
 
   var DatasetdisplayctrlCtrl,
-    scope;
+      scope;
 
   // Initialize the controller and a mock scope
   beforeEach(inject(function ($controller, $rootScope) {
     scope = $rootScope.$new();
-    DatasetdisplayctrlCtrl = $controller('DatasetdisplayctrlCtrl', {
+    DatasetdisplayctrlCtrl = $controller('DatasetDisplayCtrl', {
       $scope: scope
     });
   }));
 
-  it('should attach a list of awesomeThings to the scope', function () {
-    expect(scope.awesomeThings.length).toBe(3);
+  it('should initialize the removeDataset function', function() {
+    scope.datasets.push(1);
+    scope.datasets.push(2);
+
+    expect(scope.datasets[0]).toBe(1);
+
+    scope.removeDataset(0);
+
+    expect(scope.datasets[0]).toBe(2);
+  });
+
+  it('should initialize the removeDataset function', function() {
+    scope.datasets.push(1);
+    scope.datasets.push(2);
+
+    expect(scope.datasets[0]).toBe(1);
+
+    scope.removeDataset(0);
+
+    expect(scope.datasets[0]).toBe(2);
   });
 });


[10/19] git commit: Transition isodatetomiddleendian filter tests

Posted by jo...@apache.org.
Transition isodatetomiddleendian filter tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/bce574b5
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/bce574b5
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/bce574b5

Branch: refs/heads/master
Commit: bce574b53fd3bf3b02b24d9a39a66f14a8d3085d
Parents: e092e0f
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:47:50 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 .../test/spec/filters/isodatetomiddleendian.js  | 46 ++++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/bce574b5/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js b/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js
index 72ab650..966b333 100644
--- a/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js
+++ b/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js
@@ -30,9 +30,47 @@ describe('Filter: ISODateToMiddleEndian', function () {
     ISODateToMiddleEndian = $filter('ISODateToMiddleEndian');
   }));
 
-  it('should return the input prefixed with "ISODateToMiddleEndian filter:"', function () {
-    var text = 'angularjs';
-    expect(ISODateToMiddleEndian(text)).toBe('ISODateToMiddleEndian filter: ' + text);
-  });
+	describe('ISODateToMiddleEndian', function() {
+		it('should replace the ISO Date/Time stamp', function() {
+			inject(function($filter) {
+				var filter = $filter('ISODateToMiddleEndian');
+				expect(filter('2012-01-02T00:00:00')).toEqual('01/02/2012');
+			});
+		});
 
+		it('should replace the modified ISO Date/Time stamp', function() {
+			inject(function($filter) {
+				var filter = $filter('ISODateToMiddleEndian');
+				expect(filter('2012-01-02 00:00:00')).toEqual('01/02/2012');
+			});
+		});
+
+		it('should replace the ISO Date stamp', function() {
+			inject(function($filter) {
+				var filter = $filter('ISODateToMiddleEndian');
+				expect(filter('2012-01-02')).toEqual('01/02/2012');
+			});
+		});
+
+		it('should replace leading and trailing whitespace', function() {
+			inject(function($filter) {
+				var filter = $filter('ISODateToMiddleEndian');
+				expect(filter('      2012-01-02T00:00:00    ')).toEqual('01/02/2012');
+			});
+		});
+
+		it('should do nothing when the date format has the incorrect number of hyphens', function() {
+			inject(function($filter) {
+				var filter = $filter('ISODateToMiddleEndian');
+				expect(filter('2012-234T234')).toEqual('2012-234T234')
+			});
+		});
+
+		it('should do nothing when the date format has no hyphens', function() {
+			inject(function($filter) {
+				var filter = $filter('ISODateToMiddleEndian');
+				expect(filter('2012234T234')).toEqual('2012234T234')
+			});
+		});
+	});
 });


[09/19] git commit: Transition previewmap tests

Posted by jo...@apache.org.
Transition previewmap tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/0f824302
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/0f824302
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/0f824302

Branch: refs/heads/master
Commit: 0f824302e7c31ce7a5db195109149db4c36fcaec
Parents: ce9715b
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:41:26 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 .../test/spec/directives/previewmap.js          | 24 ++++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/0f824302/ocw-ui/frontend-new/test/spec/directives/previewmap.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/previewmap.js b/ocw-ui/frontend-new/test/spec/directives/previewmap.js
index c99f063..2a831c6 100644
--- a/ocw-ui/frontend-new/test/spec/directives/previewmap.js
+++ b/ocw-ui/frontend-new/test/spec/directives/previewmap.js
@@ -31,9 +31,23 @@ describe('Directive: previewMap', function () {
     scope = $rootScope.$new();
   }));
 
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<preview-map></preview-map>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the previewMap directive');
-  }));
+  it('should set the proper class', function() {
+    inject(function($compile, $rootScope) {
+      $rootScope.dataset = {latlonVals: {latMax: 90, lonMax: 90, latMin: -90, lonMin: -90}, name: "TRMM"};
+
+      var element = $compile('<div preview-map="dataset"></div>')($rootScope);
+
+      expect(element.hasClass("preview-map")).toBeTruthy();
+    });
+  });
+  
+  it('should set the id of the template to the name of the dataset', function() {
+    inject(function($compile, $rootScope) {
+      $rootScope.dataset = {latlonVals: {latMax: 90, lonMax: 90, latMin: -90, lonMin: -90}, name: "TRMM"};
+
+      var element = $compile('<div preview-map="dataset"></div>')($rootScope);
+
+      expect(element.attr('id')).toEqual("{{dataset.name}}");
+    });
+  });
 });


[14/19] git commit: Transition selectdatasetinformation service tests

Posted by jo...@apache.org.
Transition selectdatasetinformation service tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/c1691570
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/c1691570
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/c1691570

Branch: refs/heads/master
Commit: c1691570ef1de65ae375479de5c9454043d8414a
Parents: 459154f
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:53:11 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 .../spec/services/selecteddatasetinformation.js | 59 +++++++++++++++++++-
 1 file changed, 57 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/c1691570/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js b/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js
index 75000e9..60c1ac2 100644
--- a/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js
+++ b/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js
@@ -30,8 +30,63 @@ describe('Service: selectedDatasetInformation', function () {
     selectedDatasetInformation = _selectedDatasetInformation_;
   }));
 
-  it('should do something', function () {
-    expect(!!selectedDatasetInformation).toBe(true);
+  it('should initialize the selectedDatasetInformation service', function() {
+    inject(function(selectedDatasetInformation) {
+      expect(selectedDatasetInformation).not.toEqual(null);
+    });
   });
 
+  it('should provide the getDatasets function', function() {
+    inject(function(selectedDatasetInformation) {
+      expect(selectedDatasetInformation.getDatasets()).not.toEqual(null);
+    });
+  });
+
+  it('should provide the getDatasetCount function', function() {
+    inject(function(selectedDatasetInformation) {
+      expect(selectedDatasetInformation.getDatasetCount()).toEqual(0);
+    });
+  });
+
+  it('should provide the addDataset function', function() {
+    inject(function(selectedDatasetInformation) {
+      selectedDatasetInformation.addDataset({});
+      expect(selectedDatasetInformation.getDatasetCount()).toEqual(1);
+    });
+  });
+
+  it('should set the shouldDisplay attribute when adding a dataset', function() {
+    inject(function(selectedDatasetInformation) {
+      selectedDatasetInformation.addDataset({});
+      expect(selectedDatasetInformation.getDatasets()[0].shouldDisplay).toBe(false);
+    });
+  });
+
+  it('should set the regrid attribute when adding a dataset', function() {
+    inject(function(selectedDatasetInformation) {
+      selectedDatasetInformation.addDataset({});
+      expect(selectedDatasetInformation.getDatasets()[0].regrid).toBe(false);
+    });
+  });
+
+  it('should provide the removeDataset function', function() {
+    inject(function(selectedDatasetInformation) {
+      selectedDatasetInformation.addDataset(1);
+      selectedDatasetInformation.addDataset(2);
+
+      expect(selectedDatasetInformation.getDatasets()[0]).toEqual(1);
+      selectedDatasetInformation.removeDataset(0);
+      expect(selectedDatasetInformation.getDatasets()[0]).toEqual(2);
+    });
+  });
+
+  it('should provide the clearDatasets function', function() {
+    inject(function(selectedDatasetInformation) {
+      selectedDatasetInformation.addDataset({});
+      expect(selectedDatasetInformation.getDatasetCount()).toEqual(1);
+
+      selectedDatasetInformation.clearDatasets();
+      expect(selectedDatasetInformation.getDatasetCount()).toEqual(0);
+    });
+  });
 });


[19/19] git commit: Resolve CLIMATE-502. Merge PR #98.

Posted by jo...@apache.org.
Resolve CLIMATE-502. Merge PR #98.


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/e1a67b7f
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/e1a67b7f
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/e1a67b7f

Branch: refs/heads/master
Commit: e1a67b7f04541312274697b6a15eb97cf6409d48
Parents: e343183 819acb7
Author: Michael Joyce <jo...@apache.org>
Authored: Tue Aug 5 10:31:31 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Tue Aug 5 10:31:31 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/karma.conf.js          |  15 +-
 .../test/spec/controllers/datasetdisplay.js     |  28 ++-
 .../test/spec/controllers/datasetselect.js      |  21 +-
 .../test/spec/controllers/observationselect.js  |  98 ++++++++-
 .../test/spec/controllers/parameterselect.js    | 205 ++++++++++++++++++-
 .../test/spec/controllers/rcmedselection.js     | 112 +++++++++-
 .../test/spec/controllers/result.js             |   4 -
 .../test/spec/controllers/resultdetail.js       |   4 -
 .../test/spec/controllers/settings.js           |   4 -
 .../test/spec/controllers/timeline.js           |   4 -
 .../test/spec/controllers/worldmap.js           |  24 ++-
 .../test/spec/directives/bootstrapmodal.js      |   6 -
 .../test/spec/directives/bootstrapmodalopen.js  |   6 -
 .../test/spec/directives/leafletmap.js          |   6 -
 .../frontend-new/test/spec/directives/onblur.js |  21 +-
 .../directives/predictivefilebrowserinput.js    |   6 -
 .../test/spec/directives/previewmap.js          |  24 ++-
 .../test/spec/directives/timeline.js            |   6 -
 .../test/spec/filters/isodatetomiddleendian.js  |  46 ++++-
 .../test/spec/services/evaluationsettings.js    |  11 +-
 .../test/spec/services/regionselectparams.js    |  11 +-
 .../spec/services/selecteddatasetinformation.js |  59 +++++-
 22 files changed, 629 insertions(+), 92 deletions(-)
----------------------------------------------------------------------



[15/19] git commit: Remove placeholder directive tests

Posted by jo...@apache.org.
Remove placeholder directive tests


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/af34aaaa
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/af34aaaa
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/af34aaaa

Branch: refs/heads/master
Commit: af34aaaa067d3cde7f7821a498fc1f026cf91aa5
Parents: 0f82430
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Aug 1 13:44:02 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Aug 4 15:01:02 2014 -0700

----------------------------------------------------------------------
 ocw-ui/frontend-new/test/spec/directives/bootstrapmodal.js     | 6 ------
 ocw-ui/frontend-new/test/spec/directives/bootstrapmodalopen.js | 6 ------
 ocw-ui/frontend-new/test/spec/directives/leafletmap.js         | 6 ------
 .../test/spec/directives/predictivefilebrowserinput.js         | 6 ------
 ocw-ui/frontend-new/test/spec/directives/timeline.js           | 6 ------
 5 files changed, 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/af34aaaa/ocw-ui/frontend-new/test/spec/directives/bootstrapmodal.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/bootstrapmodal.js b/ocw-ui/frontend-new/test/spec/directives/bootstrapmodal.js
index 2e4150e..465f65e 100644
--- a/ocw-ui/frontend-new/test/spec/directives/bootstrapmodal.js
+++ b/ocw-ui/frontend-new/test/spec/directives/bootstrapmodal.js
@@ -30,10 +30,4 @@ describe('Directive: bootstrapModal', function () {
   beforeEach(inject(function ($rootScope) {
     scope = $rootScope.$new();
   }));
-
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<bootstrap-modal></bootstrap-modal>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the bootstrapModal directive');
-  }));
 });

http://git-wip-us.apache.org/repos/asf/climate/blob/af34aaaa/ocw-ui/frontend-new/test/spec/directives/bootstrapmodalopen.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/bootstrapmodalopen.js b/ocw-ui/frontend-new/test/spec/directives/bootstrapmodalopen.js
index 3cd2c4c..699210c 100644
--- a/ocw-ui/frontend-new/test/spec/directives/bootstrapmodalopen.js
+++ b/ocw-ui/frontend-new/test/spec/directives/bootstrapmodalopen.js
@@ -30,10 +30,4 @@ describe('Directive: bootstrapModalOpen', function () {
   beforeEach(inject(function ($rootScope) {
     scope = $rootScope.$new();
   }));
-
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<bootstrap-modal-open></bootstrap-modal-open>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the bootstrapModalOpen directive');
-  }));
 });

http://git-wip-us.apache.org/repos/asf/climate/blob/af34aaaa/ocw-ui/frontend-new/test/spec/directives/leafletmap.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/leafletmap.js b/ocw-ui/frontend-new/test/spec/directives/leafletmap.js
index c722ce6..85ccc6d 100644
--- a/ocw-ui/frontend-new/test/spec/directives/leafletmap.js
+++ b/ocw-ui/frontend-new/test/spec/directives/leafletmap.js
@@ -30,10 +30,4 @@ describe('Directive: leafletMap', function () {
   beforeEach(inject(function ($rootScope) {
     scope = $rootScope.$new();
   }));
-
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<leaflet-map></leaflet-map>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the leafletMap directive');
-  }));
 });

http://git-wip-us.apache.org/repos/asf/climate/blob/af34aaaa/ocw-ui/frontend-new/test/spec/directives/predictivefilebrowserinput.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/predictivefilebrowserinput.js b/ocw-ui/frontend-new/test/spec/directives/predictivefilebrowserinput.js
index 4661e96..162b361 100644
--- a/ocw-ui/frontend-new/test/spec/directives/predictivefilebrowserinput.js
+++ b/ocw-ui/frontend-new/test/spec/directives/predictivefilebrowserinput.js
@@ -30,10 +30,4 @@ describe('Directive: predictiveFileBrowserInput', function () {
   beforeEach(inject(function ($rootScope) {
     scope = $rootScope.$new();
   }));
-
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<predictive-file-browser-input></predictive-file-browser-input>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the predictiveFileBrowserInput directive');
-  }));
 });

http://git-wip-us.apache.org/repos/asf/climate/blob/af34aaaa/ocw-ui/frontend-new/test/spec/directives/timeline.js
----------------------------------------------------------------------
diff --git a/ocw-ui/frontend-new/test/spec/directives/timeline.js b/ocw-ui/frontend-new/test/spec/directives/timeline.js
index 4c61907..06c72e1 100644
--- a/ocw-ui/frontend-new/test/spec/directives/timeline.js
+++ b/ocw-ui/frontend-new/test/spec/directives/timeline.js
@@ -30,10 +30,4 @@ describe('Directive: timeline', function () {
   beforeEach(inject(function ($rootScope) {
     scope = $rootScope.$new();
   }));
-
-  it('should make hidden element visible', inject(function ($compile) {
-    element = angular.element('<timeline></timeline>');
-    element = $compile(element)(scope);
-    expect(element.text()).toBe('this is the timeline directive');
-  }));
 });