ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [12/35] git commit: AMBARI-7013. Fix UI Unit tests. (onechiporenko)
Date Wed, 27 Aug 2014 14:04:53 GMT
AMBARI-7013. Fix UI Unit tests. (onechiporenko)


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

Branch: refs/heads/branch-alerts-dev
Commit: 574461df0847b83967ec64c429387fb4859eecd0
Parents: 9094078
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Tue Aug 26 16:25:07 2014 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Tue Aug 26 16:25:07 2014 +0300

----------------------------------------------------------------------
 ambari-web/test/app_test.js                     | 52 --------------------
 .../dashboard/config_history_controller_test.js | 25 +++++++---
 ambari-web/test/utils/date_test.js              |  4 +-
 .../common/configs/config_history_flow_test.js  |  6 +--
 4 files changed, 23 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/574461df/ambari-web/test/app_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js
index c16d5f0..85b50ee 100644
--- a/ambari-web/test/app_test.js
+++ b/ambari-web/test/app_test.js
@@ -81,58 +81,6 @@ describe('App', function () {
     });
   });
 
-  describe('#stack2VersionURL', function () {
-
-    var testCases = [
-      {
-        title: 'if currentStackVersion and defaultStackVersion are empty then stack2VersionURL
should contain prefix',
-        currentStackVersion: '',
-        defaultStackVersion: '',
-        result: '/stacks2/HDP/versions/'
-      },
-      {
-        title: 'if currentStackVersion is "HDP-1.3.1" then stack2VersionURL should be "/stacks2/HDP/versions/1.3.1"',
-        currentStackVersion: 'HDP-1.3.1',
-        defaultStackVersion: '',
-        result: '/stacks2/HDP/versions/1.3.1'
-      },
-      {
-        title: 'if defaultStackVersion is "HDP-1.3.1" then stack2VersionURL should be "/stacks/HDP/versions/1.3.1"',
-        currentStackVersion: '',
-        defaultStackVersion: 'HDP-1.3.1',
-        result: '/stacks2/HDP/versions/1.3.1'
-      },
-      {
-        title: 'if defaultStackVersion and currentStackVersion are different then stack2VersionURL
should have currentStackVersion value',
-        currentStackVersion: 'HDP-1.3.2',
-        defaultStackVersion: 'HDP-1.3.1',
-        result: '/stacks2/HDP/versions/1.3.2'
-      },
-      {
-        title: 'if defaultStackVersion is "HDPLocal-1.3.1" then stack2VersionURL should be
"/stacks2/HDPLocal/versions/1.3.1"',
-        currentStackVersion: '',
-        defaultStackVersion: 'HDPLocal-1.3.1',
-        result: '/stacks2/HDPLocal/versions/1.3.1'
-      },
-      {
-        title: 'if currentStackVersion is "HDPLocal-1.3.1" then stack2VersionURL should be
"/stacks2/HDPLocal/versions/1.3.1"',
-        currentStackVersion: 'HDPLocal-1.3.1',
-        defaultStackVersion: '',
-        result: '/stacks2/HDPLocal/versions/1.3.1'
-      }
-    ];
-
-    testCases.forEach(function (test) {
-      it(test.title, function () {
-        App.set('currentStackVersion', test.currentStackVersion);
-        App.set('defaultStackVersion', test.defaultStackVersion);
-        expect(App.get('stack2VersionURL')).to.equal(test.result);
-        App.set('currentStackVersion', "HDP-1.2.2");
-        App.set('defaultStackVersion', "HDP-1.2.2");
-      });
-    });
-  });
-
   describe('#falconServerURL', function () {
 
     var testCases = [

http://git-wip-us.apache.org/repos/asf/ambari/blob/574461df/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
index 257e012..0692b9e 100644
--- a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
+++ b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
@@ -28,11 +28,11 @@ describe('MainConfigHistoryController', function () {
   describe('#realUrl', function () {
     it('cluster name is empty', function () {
       App.set('clusterName', '');
-      expect(controller.get('realUrl')).to.equal('/api/v1/clusters//configurations/serviceconfigversions?<parameters>fields=serviceconfigversion,user,appliedtime,createtime,service_name,service_config_version_note&minimal_response=true');
+      expect(controller.get('realUrl')).to.equal('/api/v1/clusters//configurations/serviceconfigversions?<parameters>fields=serviceconfigversion,user,group_id,group_name,createtime,service_name,service_config_version_note&minimal_response=true');
     });
     it('cluster name is "mycluster"', function () {
       App.set('clusterName', 'mycluster');
-      expect(controller.get('realUrl')).to.equal('/api/v1/clusters/mycluster/configurations/serviceconfigversions?<parameters>fields=serviceconfigversion,user,appliedtime,createtime,service_name,service_config_version_note&minimal_response=true');
+      expect(controller.get('realUrl')).to.equal('/api/v1/clusters/mycluster/configurations/serviceconfigversions?<parameters>fields=serviceconfigversion,user,group_id,group_name,createtime,service_name,service_config_version_note&minimal_response=true');
     });
   });
   describe('#load()', function () {
@@ -122,20 +122,31 @@ describe('MainConfigHistoryController', function () {
     });
     afterEach(function () {
       App.router.get.restore();
+      App.get.restore();
     });
     it('testMode is true', function () {
-      App.set('testMode', true);
+      sinon.stub(App, 'get', function(k) {
+        if ('testMode' === k) return true;
+        return Em.get(App, k);
+      });
       expect(controller.getUrl()).to.equal('/data/configurations/service_versions.json');
     });
     it('query params is empty', function () {
-      App.set('testMode', false);
-      expect(controller.getUrl()).to.equal('/api/v1/clusters/mycluster/configurations/serviceconfigversions?fields=serviceconfigversion,user,appliedtime,createtime,service_name,service_config_version_note&minimal_response=true');
+      sinon.stub(App, 'get', function(k) {
+        if ('testMode' === k) return false;
+        return Em.get(App, k);
+      });
+      expect(controller.getUrl()).to.equal('/api/v1/clusters/mycluster/configurations/serviceconfigversions?fields=serviceconfigversion,user,group_id,group_name,createtime,service_name,service_config_version_note&minimal_response=true');
     });
     it('query params is correct', function () {
-      App.set('testMode', false);
-      expect(controller.getUrl({})).to.equal('/api/v1/clusters/mycluster/configurations/serviceconfigversions?paramsfields=serviceconfigversion,user,appliedtime,createtime,service_name,service_config_version_note&minimal_response=true');
+      sinon.stub(App, 'get', function(k) {
+        if ('testMode' === k) return false;
+        return Em.get(App, k);
+      });
+      expect(controller.getUrl({})).to.equal('/api/v1/clusters/mycluster/configurations/serviceconfigversions?paramsfields=serviceconfigversion,user,group_id,group_name,createtime,service_name,service_config_version_note&minimal_response=true');
     });
   });
+
   describe('#doPolling()', function () {
     beforeEach(function () {
       sinon.stub(controller, 'load', function(){

http://git-wip-us.apache.org/repos/asf/ambari/blob/574461df/ambari-web/test/utils/date_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/date_test.js b/ambari-web/test/utils/date_test.js
index 5644894..97c7048 100644
--- a/ambari-web/test/utils/date_test.js
+++ b/ambari-web/test/utils/date_test.js
@@ -89,7 +89,7 @@ describe('date', function () {
     it('Today timestamp', function() {
       var now = new Date();
       var then = new Date(now.getFullYear(),now.getUTCMonth(),now.getUTCDate(),0,0,0);
-      expect(date.dateFormatShort(then.getTime() + 10*3600*1000)).to.equal('Today 10:00:00');
+      expect(date.dateFormatShort(then.getTime() + 10*3600*1000)).to.contain('Today 10:00:00');
     });
     describe('Incorrect timestamps', function() {
       incorrect_tests.forEach(function(test) {
@@ -109,7 +109,7 @@ describe('date', function () {
       { t: today, e: ''}
     ];
     tests.forEach(function(test) {
-      var testMessage = 'should conver {0} to {1}'.format(test.t, test.e);
+      var testMessage = 'should convert {0} to {1}'.format(test.t, test.e);
       it(testMessage, function() {
         expect(date.startTime(test.t)).to.be.eql(test.e);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/574461df/ambari-web/test/views/common/configs/config_history_flow_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/config_history_flow_test.js b/ambari-web/test/views/common/configs/config_history_flow_test.js
index ba24dab..3317550 100644
--- a/ambari-web/test/views/common/configs/config_history_flow_test.js
+++ b/ambari-web/test/views/common/configs/config_history_flow_test.js
@@ -508,11 +508,11 @@ describe('App.ConfigHistoryFlowView', function () {
   });
 
   describe('#compare()', function () {
-    it('', function () {
+    it('should set compareServiceVersion', function () {
       sinon.spy(view.get('controller'), 'onConfigGroupChange');
-      view.compare({context: {version: 1}});
+      view.compare({context: Em.Object.create({version: 1})});
 
-      expect(view.get('controller.compareServiceVersion')).to.eql({version: 1});
+      expect(view.get('controller.compareServiceVersion.version')).to.equal(1);
       expect(view.get('controller').onConfigGroupChange.calledOnce).to.be.true;
       view.get('controller').onConfigGroupChange.restore();
     });


Mime
View raw message