浏览代码

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

Jaimin Jetly 10 年之前
父节点
当前提交
b803c9e462

+ 1 - 0
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>

+ 0 - 2
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',

+ 9 - 16
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 () {

+ 2 - 2
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'})]})
           ]
         }
       });

+ 3 - 0
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 = [],

+ 6 - 5
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);

+ 6 - 6
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]);
       });
     });
   });