ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-7554. Fix UI unit tests. (jaimin)
Date Tue, 30 Sep 2014 22:02:23 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d284e7196 -> b803c9e46


AMBARI-7554. Fix UI unit tests. (jaimin)


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

Branch: refs/heads/trunk
Commit: b803c9e4629a0120d355fdbeb46c7931f45d09c3
Parents: d284e71
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Tue Sep 30 15:02:08 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Tue Sep 30 15:02:21 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/assets/test/test.html            |  1 +
 ambari-web/app/assets/test/tests.js             |  2 --
 .../test/controllers/main/host/details_test.js  | 25 +++++++-------------
 .../test/controllers/wizard/step3_test.js       |  4 ++--
 .../test/controllers/wizard/step7_test.js       |  3 +++
 ambari-web/test/utils/ajax/ajax_test.js         | 11 +++++----
 .../widgets/uptime_text_widget_test.js          | 12 +++++-----
 7 files changed, 27 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/app/assets/test/test.html
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/test.html b/ambari-web/app/assets/test/test.html
index 8d9383a..d8ee080 100644
--- a/ambari-web/app/assets/test/test.html
+++ b/ambari-web/app/assets/test/test.html
@@ -44,6 +44,7 @@
     mocha.ui('bdd');
     mocha.reporter('html');
     expect = chai.expect;
+    assert = chai.assert;
 </script>
 <script src="./javascripts/test.js"></script>
 <script src="./tests.js"></script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 652c751..29b5be3 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -81,7 +81,6 @@ var files = ['test/init_model_test',
   'test/controllers/main/service_test',
   'test/controllers/main/admin_test',
   'test/controllers/main/alerts_controller_test',
-  'test/controllers/main/mirroring/edit_dataset_controller_test',
   'test/controllers/installer_test',
   'test/controllers/wizard_test',
   'test/controllers/wizard/step0_test',
@@ -161,7 +160,6 @@ var files = ['test/init_model_test',
   'test/views/main/host/details/host_component_views/decommissionable_test',
   'test/views/main/charts/heatmap/heatmap_host_test',
   'test/views/main/service/info/config_test',
-  'test/views/main/mirroring/edit_dataset_view_test',
   'test/views/common/configs/services_config_test',
   'test/views/wizard/step3/hostLogPopupBody_view_test',
   'test/views/wizard/step3/hostWarningPopupBody_view_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index bc4159a..9511c27 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -185,6 +185,9 @@ describe('App.MainHostDetailsController', function () {
       sinon.spy(App, "showConfirmationPopup");
       sinon.stub(controller, "addClientComponent", Em.K);
       sinon.stub(controller, "primary", Em.K);
+      controller.set('content', {hostComponents: [Em.Object.create({
+        componentName: "HDFS_CLIENT"
+      })]});
     });
 
     afterEach(function () {
@@ -206,34 +209,24 @@ describe('App.MainHostDetailsController', function () {
     });
     it('add slave component, securityEnabled = true', function () {
       var event = {context: Em.Object.create({
-        componentName: 'COMP1'
+        componentName: 'HIVE_CLIENT'
       })};
       controller.set('mockSecurityStatus', true);
       var popup = controller.addComponent(event);
       expect(App.showConfirmationPopup.calledOnce).to.be.true;
       popup.onPrimary();
       expect(controller.primary.calledWith(Em.Object.create({
-        componentName: 'COMP1'
+        componentName: 'HIVE_CLIENT'
       }))).to.be.true;
     });
     it('add slave component, securityEnabled = false', function () {
       var event = {context: Em.Object.create({
-        componentName: 'COMP1'
+        componentName: 'HIVE_CLIENT'
       })};
       controller.set('mockSecurityStatus', false);
       controller.addComponent(event);
       expect(controller.addClientComponent.calledWith(Em.Object.create({
-        componentName: 'COMP1'
-      }))).to.be.true;
-    });
-    it('add CLIENTS', function () {
-      var event = {context: Em.Object.create({
-        componentName: 'CLIENTS'
-      })};
-      controller.set('mockSecurityStatus', true);
-      controller.addComponent(event);
-      expect(controller.addClientComponent.calledWith(Em.Object.create({
-        componentName: 'CLIENTS'
+        componentName: 'HIVE_CLIENT'
       }))).to.be.true;
     });
   });
@@ -457,8 +450,8 @@ describe('App.MainHostDetailsController', function () {
         id: 'HIVE',
         service_name: 'HIVE'
       });
-      var data = {Clusters: {desired_configs: {'webhcat-site': {tag: 1}}}};
-      expect(controller.constructConfigUrlParams(data)).to.eql(['(type=webhcat-site&tag=1)']);
+      var data = {Clusters: {desired_configs: {'webhcat-site': {tag: 1},'hive-site': {tag:
1}}}};
+      expect(controller.constructConfigUrlParams(data)).to.eql(['(type=webhcat-site&tag=1)','(type=hive-site&tag=1)']);
       App.Service.find().clear();
     });
     it('STORM is installed', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index 8ed17ad..76e2e88 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -1667,7 +1667,7 @@ describe('App.WizardStep3Controller', function () {
       c.reopen({
         content: {
           stacks: [
-            Em.Object.create({isSelected: true, operatingSystems: [{selected: true, osType:
osType}]})
+            Em.Object.create({isSelected: true, operatingSystems: [Em.Object.create({isSelected:
true, osType: osType})]})
           ]
         }
       });
@@ -1678,7 +1678,7 @@ describe('App.WizardStep3Controller', function () {
       c.reopen({
         content: {
           stacks: [
-            Em.Object.create({isSelected: true, operatingSystems: [{selected: true, osType:
'os1'}]})
+            Em.Object.create({isSelected: true, operatingSystems: [Em.Object.create({isSelected:
true, osType: 'os1'})]})
           ]
         }
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 7ea1a3b..e47316e 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -500,6 +500,8 @@ describe('App.InstallerStep7Controller', function () {
       installerStep7Controller.reopen({
         stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName,
configGroups: configGroups})]
       });
+      var manageCGController = App.router.get('manageConfigGroupsController');
+      sinon.stub(manageCGController, 'hostsToPublic', function(data){return ['c6401','c6402','c6403']});
       installerStep7Controller.loadConfigGroups(serviceConfigGroups);
       expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
       var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
@@ -509,6 +511,7 @@ describe('App.InstallerStep7Controller', function () {
       expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
       expect(group.get('service.id')).to.equal(serviceName);
       expect(group.get('serviceName')).to.equal(serviceName);
+      manageCGController.hostsToPublic.restore();
     });
     it('should update configGroups for service (only default group)', function () {
       var configGroups = [],

http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/test/utils/ajax/ajax_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/ajax/ajax_test.js b/ambari-web/test/utils/ajax/ajax_test.js
index d0d9ead..3b692bd 100644
--- a/ambari-web/test/utils/ajax/ajax_test.js
+++ b/ambari-web/test/utils/ajax/ajax_test.js
@@ -24,15 +24,16 @@ describe('App.ajax', function() {
   beforeEach(function() {
     App.set('apiPrefix', '/api/v1');
     App.set('clusterName', 'tdk');
-    sinon.spy($, 'ajax');
-  });
-
-  afterEach(function() {
-    $.ajax.restore();
   });
 
   describe('#send', function() {
+    beforeEach(function() {
+      sinon.spy($, 'ajax');
+    });
 
+    afterEach(function() {
+      $.ajax.restore();
+    });
     it('Without sender', function() {
       expect(App.ajax.send({})).to.equal(null);
       expect($.ajax.called).to.equal(false);

http://git-wip-us.apache.org/repos/asf/ambari/blob/b803c9e4/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
index 7baec59..d11c791 100644
--- a/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/uptime_text_widget_test.js
@@ -17,7 +17,6 @@
  */
 
 var App = require('app');
-
 require('views/main/dashboard/widget');
 require('views/main/dashboard/widgets/text_widget');
 require('views/main/dashboard/widgets/uptime_text_widget');
@@ -25,19 +24,20 @@ require('views/main/dashboard/widgets/uptime_text_widget');
 describe('App.UptimeTextDashboardWidgetView', function() {
 
   describe('#timeConverter', function() {
+    var ts1 = 1358245370553, ts2 = 0;
     var timestamps = [
       {
-        t: 1358245370553,
+        t: ts1,
         e: {
           l: 2,
-          f: 'Tue Jan 15 2013'
+          f: new Date(ts1)
         }
       },
       {
-        t: 0,
+        t: ts2,
         e: {
           l: 2,
-          f: 'Thu Jan 01 1970'
+          f: new Date(ts2)
         }
       }
     ];
@@ -46,7 +46,7 @@ describe('App.UptimeTextDashboardWidgetView', function() {
       it('timestamp ' + timestamp.t, function() {
         var result = uptimeTextDashboardWidgetView.timeConverter(timestamp.t);
         expect(result.length).to.equal(timestamp.e.l);
-        expect(result[0]).to.equal(timestamp.e.f);
+        assert.include(timestamp.e.f.toString(), result[0].toString(), timestamp.e.f + '
contains string ' + result[0]);
       });
     });
   });


Mime
View raw message