http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js
 
b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js
index 0ab3ea3..2babb01 100644
--- 
a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js
+++ 
b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js
@@ -77,38 +77,70 @@ describe('MainChartHeatmapMetric', function () {
   });
 
   describe('#generateSlot()', function () {
+
     beforeEach(function () {
       sinon.stub(mainChartHeatmapMetric, 'formatLegendNumber').returns('val');
       sinon.stub(date, 'timingFormat').returns('time');
     });
+
     afterEach(function () {
       mainChartHeatmapMetric.formatLegendNumber.restore();
       date.timingFormat.restore();
     });
-    it('label suffix is empty', function () {
-      expect(mainChartHeatmapMetric.generateSlot(0, 1, '', {r: 0, g: 0, b: 
0})).to.eql(Em.Object.create({
-        "from": "val",
-        "to": "val",
-        "label": "val - val",
-        "cssStyle": "background-color:rgb(0,0,0)"
-      }));
-
-      
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(0).args).to.eql([0]);
-      
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(1).args).to.eql([1]);
+
+    describe('label suffix is empty', function () {
+
+      beforeEach(function () {
+        this.result = mainChartHeatmapMetric.generateSlot(0, 1, '', {r: 0, g: 
0, b: 0});
+      });
+
+      it('generateSlot result is valid', function () {
+        expect(this.result).to.eql(Em.Object.create({
+          "from": "val",
+          "to": "val",
+          "label": "val - val",
+          "cssStyle": "background-color:rgb(0,0,0)"
+        }));
+      });
+
+      it('formatLegendNumber 1st call with valid arguments', function () {
+        
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(0).args).to.eql([0]);
+      });
+
+      it('formatLegendNumber 2nd call with valid arguments', function () {
+        
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(1).args).to.eql([1]);
+      });
     });
-    it('label suffix is "ms"', function () {
-      expect(mainChartHeatmapMetric.generateSlot(0, 1, 'ms', {r: 0, g: 0, b: 
0})).to.eql(Em.Object.create({
-        "from": "val",
-        "to": "val",
-        "label": "time - time",
-        "cssStyle": "background-color:rgb(0,0,0)"
-      }));
-
-      
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(0).args).to.eql([0]);
-      
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(1).args).to.eql([1]);
-      expect(date.timingFormat.getCall(0).args).to.eql(['val', 'zeroValid']);
-      expect(date.timingFormat.getCall(1).args).to.eql(['val', 'zeroValid']);
+
+    describe('label suffix is "ms"', function () {
+
+      beforeEach(function () {
+        this.result = mainChartHeatmapMetric.generateSlot(0, 1, 'ms', {r: 0, 
g: 0, b: 0});
+      });
+
+      it('generateSlot result is valid', function () {
+        expect(this.result).to.eql(Em.Object.create({
+          "from": "val",
+          "to": "val",
+          "label": "time - time",
+          "cssStyle": "background-color:rgb(0,0,0)"
+        }));
+      });
+      it('formatLegendNumber 1st call with valid arguments', function () {
+        
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(0).args).to.eql([0]);
+      });
+      it('formatLegendNumber 2nd call with valid arguments', function () {
+        
expect(mainChartHeatmapMetric.formatLegendNumber.getCall(1).args).to.eql([1]);
+      });
+      it('timingFormat 1st call with valid arguments', function () {
+        expect(date.timingFormat.getCall(0).args).to.eql(['val', 'zeroValid']);
+      });
+      it('timingFormat 2nd call with valid arguments', function () {
+        expect(date.timingFormat.getCall(1).args).to.eql(['val', 'zeroValid']);
+      });
+
     });
+
   });
 
   describe('#getHatchStyle()', function () {
@@ -159,6 +191,15 @@ describe('MainChartHeatmapMetric', function () {
   });
 
   describe('#hostToSlotMap', function () {
+
+    beforeEach(function () {
+      this.stub = sinon.stub(mainChartHeatmapMetric, 'calculateSlot');
+    });
+
+    afterEach(function () {
+      this.stub.restore();
+    });
+
     it('hostToValueMap is null', function () {
       mainChartHeatmapMetric.set('hostToValueMap', null);
       mainChartHeatmapMetric.set('hostNames', []);
@@ -174,20 +215,18 @@ describe('MainChartHeatmapMetric', function () {
     it('slot greater than -1', function () {
       mainChartHeatmapMetric.set('hostToValueMap', {});
       mainChartHeatmapMetric.set('hostNames', ['host1']);
-      sinon.stub(mainChartHeatmapMetric, 'calculateSlot').returns(0);
+      this.stub.returns(0);
       mainChartHeatmapMetric.propertyDidChange('hostToSlotMap');
       expect(mainChartHeatmapMetric.get('hostToSlotMap')).to.eql({'host1': 0});
       expect(mainChartHeatmapMetric.calculateSlot.calledWith({}, 
'host1')).to.be.true;
-      mainChartHeatmapMetric.calculateSlot.restore();
     });
     it('slot equal to -1', function () {
       mainChartHeatmapMetric.set('hostToValueMap', {});
       mainChartHeatmapMetric.set('hostNames', ['host1']);
-      sinon.stub(mainChartHeatmapMetric, 'calculateSlot').returns('-1');
+      this.stub.returns('-1');
       mainChartHeatmapMetric.propertyDidChange('hostToSlotMap');
       expect(mainChartHeatmapMetric.get('hostToSlotMap')).to.be.empty;
       expect(mainChartHeatmapMetric.calculateSlot.calledWith({}, 
'host1')).to.be.true;
-      mainChartHeatmapMetric.calculateSlot.restore();
     });
   });
 
@@ -272,10 +311,20 @@ describe('MainChartHeatmapMetric', function () {
     ];
 
     testCases.forEach(function (test) {
-      it(test.title, function () {
-        sinon.stub(mainChartHeatmapMetric, 
'get').withArgs('slotDefinitions').returns(test.data.slotDefinitions);
-        expect(mainChartHeatmapMetric.calculateSlot(test.data.hostToValueMap, 
test.data.hostName)).to.equal(test.result);
-        mainChartHeatmapMetric.get.restore();
+      describe(test.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(mainChartHeatmapMetric, 
'get').withArgs('slotDefinitions').returns(test.data.slotDefinitions);
+        });
+
+        afterEach(function () {
+          mainChartHeatmapMetric.get.restore();
+        });
+
+        it('calculateSlot result is valid', function () {
+          
expect(mainChartHeatmapMetric.calculateSlot(test.data.hostToValueMap, 
test.data.hostName)).to.equal(test.result);
+        });
+
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/charts/heatmap_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_test.js 
b/ambari-web/test/controllers/main/charts/heatmap_test.js
index 1dca028..2e3f9de 100644
--- a/ambari-web/test/controllers/main/charts/heatmap_test.js
+++ b/ambari-web/test/controllers/main/charts/heatmap_test.js
@@ -53,11 +53,11 @@ describe('MainChartsHeatmapController', function () {
       controller.set("inputMaximum", 'qwerty');
       expect(controller.get('selectedMetric.maximumValue')).to.equal(100);
     });
-    it('should not set maximumValue if inputMaximum consists not only of 
digits', function () {
+    it('should not set maximumValue if inputMaximum consists not only of 
digits (2)', function () {
       controller.set("inputMaximum", '100%');
       expect(controller.get('selectedMetric.maximumValue')).to.equal(100);
     });
-    it('should set maximumValue if inputMaximum consists only of digits', 
function () {
+    it('should set maximumValue if inputMaximum consists only of digits (2)', 
function () {
       controller.set("inputMaximum", 1000);
       expect(controller.get('selectedMetric.maximumValue')).to.equal(1000);
     })
@@ -361,16 +361,14 @@ describe('MainChartsHeatmapController', function () {
   });
 
   describe("#toList()", function() {
-    it("", function() {
-      var rackMap = {'r1': {
-        name: 'r1',
-        rackId: 'r1',
-        hosts: [{rack: 'r1'}, {rack: 'r1'}]
-      }};
-      expect(controller.toList(rackMap)).to.eql([Em.Object.create({
-        name: 'r1',
-        rackId: 'r1',
-        hosts: [{rack: 'r1'}, {rack: 'r1'}],
+    var rackMap = {'r1': {
+      name: 'r1',
+      rackId: 'r1',
+      hosts: [{rack: 'r1'}, {rack: 'r1'}]
+    }};
+
+    it('toList result is valid', function() {
+      expect(controller.toList(rackMap)).to.eql([Em.Object.create(rackMap.r1, {
         isLoaded: false,
         index: 0
       })]);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/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 24497b6..7467bca 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
@@ -113,30 +113,20 @@ describe('MainConfigHistoryController', function () {
           }
         }
       });
+      sinon.stub(App, 'get', function(k) {
+        if ('testMode' === k) return false;
+        return Em.get(App, k);
+      });
     });
     afterEach(function () {
       App.router.get.restore();
       App.get.restore();
     });
-    it('testMode is true', function () {
-      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 () {
-      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/service_config_versions?fields=service_config_version,user,group_id,group_name,is_current,createtime,service_name,hosts,service_config_version_note,is_cluster_compatible,stack_id&minimal_response=true');
     });
     it('query params is correct', function () {
-      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/service_config_versions?params&fields=service_config_version,user,group_id,group_name,is_current,createtime,service_name,hosts,service_config_version_note,is_cluster_compatible,stack_id&minimal_response=true');
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/host/configs_service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/configs_service_test.js 
b/ambari-web/test/controllers/main/host/configs_service_test.js
index 616574c..d715df7 100644
--- a/ambari-web/test/controllers/main/host/configs_service_test.js
+++ b/ambari-web/test/controllers/main/host/configs_service_test.js
@@ -118,17 +118,23 @@ describe('App.MainHostServiceConfigsController', function 
() {
        });
 
        describe("#renderServiceConfigs()", function () {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'filterServiceConfigs', function () {
+        this._super = Em.K;
+      });
+    });
+
+    afterEach(function () {
+      controller.filterServiceConfigs.restore();
+    });
+
                it("should call filterServiceConfigs", function () {
                        var serviceConfigs = {
                                configCategories: 'val'
                        };
-                       sinon.stub(controller, 'filterServiceConfigs', function 
() {
-                               this._super = Em.K;
-                       });
                        controller.renderServiceConfigs(serviceConfigs);
-
                        
expect(controller.filterServiceConfigs.calledWith('val')).to.be.true;
-                       controller.filterServiceConfigs.restore();
                });
        });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/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 947ec82..27bd38f 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -50,32 +50,51 @@ describe('App.MainHostDetailsController', function () {
   App.TestAliases.testAsComputedFilterBy(getController(), 
'serviceNonClientActiveComponents', 'serviceActiveComponents', 'isClient', 
false);
 
   describe('#routeHome()', function () {
-    it('transiotion to dashboard', function () {
+
+    beforeEach(function () {
       sinon.stub(App.router, 'transitionTo', Em.K);
+    });
+
+    afterEach(function () {
+      App.router.transitionTo.restore();
+    });
+
+    it('transition to dashboard', function () {
       controller.routeHome();
       
expect(App.router.transitionTo.calledWith('main.dashboard.index')).to.be.true;
-      App.router.transitionTo.restore();
     });
   });
 
   describe('#startComponent()', function () {
-    it('call sendComponentCommand', function () {
-      var event = {
-        context: Em.Object.create({
-          displayName: 'comp'
-        })
-      };
+
+    var event = {
+      context: Em.Object.create({
+        displayName: 'comp'
+      })
+    };
+
+    beforeEach(function () {
       sinon.stub(App, 'showConfirmationPopup', function (callback) {
         callback();
       });
       sinon.stub(controller, 'sendComponentCommand');
       controller.startComponent(event);
+    });
+
+    afterEach(function () {
+      App.showConfirmationPopup.restore();
+      controller.sendComponentCommand.restore();
+    });
+
+    it('configmation popup is shown', function () {
       expect(App.showConfirmationPopup.calledOnce).to.be.true;
+    });
+
+    it('call sendComponentCommand', function () {
       expect(controller.sendComponentCommand.calledWith(Em.Object.create({
         displayName: 'comp'
       })), Em.I18n.t('requestInfo.startHostComponent') + " comp", 
App.HostComponentStatus.started).to.be.true;
-      App.showConfirmationPopup.restore();
-      controller.sendComponentCommand.restore();
+
     });
   });
 
@@ -181,65 +200,45 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#sendComponentCommandSuccessCallback()', function () {
+
+    var params = {
+      component: Em.Object.create({}),
+      HostRoles: {
+        state: App.HostComponentStatus.stopped
+      }
+    };
+
     beforeEach(function () {
       sinon.stub(controller, 'mimicWorkStatusChange', Em.K);
       sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
+      sinon.stub(App, 'get').withArgs('testMode').returns(false);
+      controller.sendComponentCommandSuccessCallback({}, {}, params);
     });
+
     afterEach(function () {
       controller.showBackgroundOperationsPopup.restore();
       controller.mimicWorkStatusChange.restore();
+      App.get.restore();
     });
-    it('testMode, starting component', function () {
-      var params = {
-        component: Em.Object.create({}),
-        HostRoles: {
-          state: App.HostComponentStatus.started
-        }
-      };
-
-      App.set('testMode', true);
-      controller.sendComponentCommandSuccessCallback({}, {}, params);
-      expect(controller.mimicWorkStatusChange.calledWith(Em.Object.create({
-        workStatus: App.HostComponentStatus.starting
-      }), App.HostComponentStatus.starting, 
App.HostComponentStatus.started)).to.be.true;
-      expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
-    });
-    it('testMode, stopping component', function () {
-      var params = {
-        component: Em.Object.create({}),
-        HostRoles: {
-          state: App.HostComponentStatus.stopped
-        }
-      };
-
-      App.set('testMode', true);
-      controller.sendComponentCommandSuccessCallback({}, {}, params);
-      expect(controller.mimicWorkStatusChange.calledWith(Em.Object.create({
-        workStatus: App.HostComponentStatus.stopping
-      }), App.HostComponentStatus.stopping, 
App.HostComponentStatus.stopped)).to.be.true;
-      expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
-    });
-    it('testMode, stopping component', function () {
-      var params = {
-        component: Em.Object.create({}),
-        HostRoles: {
-          state: App.HostComponentStatus.stopped
-        }
-      };
 
-      App.set('testMode', false);
-      controller.sendComponentCommandSuccessCallback({}, {}, params);
+    it('mimicWorkStatusChange is not called', function () {
       expect(controller.mimicWorkStatusChange.called).to.be.false;
+    });
+    it('showBackgroundOperationsPopup is called once', function () {
       expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
     });
   });
 
   describe('#ajaxErrorCallback()', function () {
-    it('call mainServiceItemController.ajaxErrorCallback', function () {
+    beforeEach(function () {
       sinon.stub(controller, 'ajaxErrorCallback', Em.K);
+    });
+    afterEach(function () {
+      controller.ajaxErrorCallback.restore();
+    });
+    it('call mainServiceItemController.ajaxErrorCallback', function () {
       controller.ajaxErrorCallback('request', 'ajaxOptions', 'error', 'opt', 
'params');
       expect(controller.ajaxErrorCallback.calledWith('request', 'ajaxOptions', 
'error', 'opt', 'params')).to.be.true;
-      controller.ajaxErrorCallback.restore();
     });
   });
 
@@ -252,6 +251,7 @@ describe('App.MainHostDetailsController', function () {
     var bgController = {
       showPopup: Em.K
     };
+
     beforeEach(function () {
       var stub = sinon.stub(App.router, 'get');
       stub.withArgs('userSettingsController').returns({
@@ -262,25 +262,28 @@ describe('App.MainHostDetailsController', function () {
       stub.withArgs('backgroundOperationsController').returns(bgController);
       sinon.spy(bgController, 'showPopup');
       sinon.spy(mock, 'done');
+      this.callback = sinon.stub();
     });
+
     afterEach(function () {
       bgController.showPopup.restore();
       mock.done.restore();
       App.router.get.restore();
     });
+
     it('initValue is true, callback is undefined', function () {
       mock.initValue = true;
       controller.showBackgroundOperationsPopup();
       expect(mock.done.calledOnce).to.be.true;
       expect(bgController.showPopup.calledOnce).to.be.true;
     });
+
     it('initValue is false, callback is defined', function () {
       mock.initValue = false;
-      var callback = sinon.stub();
-      controller.showBackgroundOperationsPopup(callback);
+      controller.showBackgroundOperationsPopup(this.callback);
       expect(mock.done.calledOnce).to.be.true;
       expect(bgController.showPopup.calledOnce).to.be.false;
-      expect(callback.calledOnce).to.be.true;
+      expect(this.callback.calledOnce).to.be.true;
     });
   });
 
@@ -901,6 +904,7 @@ describe('App.MainHostDetailsController', function () {
       App.Service.find().clear();
       expect(controller.constructConfigUrlParams(data)).to.eql([]);
     });
+
     it('isHaEnabled = true', function () {
       App.store.load(App.Service, {
         id: 'HDFS',
@@ -916,6 +920,7 @@ describe('App.MainHostDetailsController', function () {
       });
       App.set('currentStackVersion', 'HDP-2.0.1');
     });
+
     it('HBASE is installed', function () {
       App.store.load(App.Service, {
         id: 'HBASE',
@@ -926,6 +931,7 @@ describe('App.MainHostDetailsController', function () {
       
expect(controller.constructConfigUrlParams(data)).to.eql(['(type=hbase-site&tag=1)']);
       App.Service.find().clear();
     });
+
     it('HIVE is installed', function () {
       App.store.load(App.Service, {
         id: 'HIVE',
@@ -935,6 +941,7 @@ describe('App.MainHostDetailsController', function () {
       
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 () {
       App.store.load(App.Service, {
         id: 'STORM',
@@ -944,6 +951,7 @@ describe('App.MainHostDetailsController', function () {
       
expect(controller.constructConfigUrlParams(data)).to.eql(['(type=storm-site&tag=1)']);
       App.Service.find().clear();
     });
+
     it('YARN for 2.2 stack is installed', function () {
       App.set('currentStackVersion', 'HDP-2.2.0');
       App.store.load(App.Service, {
@@ -955,11 +963,20 @@ describe('App.MainHostDetailsController', function () {
       App.set('currentStackVersion', 'HDP-2.0.1');
       App.Service.find().clear();
     });
-    it('isRMHaEnabled true', function () {
-      sinon.stub(App, 'get').withArgs('isRMHaEnabled').returns(true);
-      var data = {Clusters: {desired_configs: {'yarn-site': {tag: 1}, 
'zoo.cfg': {tag: 1}}}};
-      
expect(controller.constructConfigUrlParams(data)).to.eql(['(type=yarn-site&tag=1)',
 '(type=zoo.cfg&tag=1)']);
-      App.get.restore();
+
+    describe('isRMHaEnabled true', function () {
+      beforeEach(function () {
+        sinon.stub(App, 'get').withArgs('isRMHaEnabled').returns(true);
+      });
+      afterEach(function () {
+        App.get.restore();
+      });
+
+      it('params are valid', function () {
+        var data = {Clusters: {desired_configs: {'yarn-site': {tag: 1}, 
'zoo.cfg': {tag: 1}}}};
+        
expect(controller.constructConfigUrlParams(data)).to.eql(['(type=yarn-site&tag=1)',
 '(type=zoo.cfg&tag=1)']);
+      });
+
     });
   });
 
@@ -1056,20 +1073,33 @@ describe('App.MainHostDetailsController', function () {
     });
 
     yarnCases.forEach(function (item) {
-      it(item.title, function () {
+      describe(item.title, function () {
         var servicesMock = item.isYARNInstalled ? [
           {
             serviceName: 'YARN'
           }
         ] : [];
-        sinon.stub(App, 
'get').withArgs('isHadoop22Stack').returns(item.isHadoop22Stack).
-          withArgs('isRMHaEnabled').returns(item.isRMHaEnabled);
-        sinon.stub(App.Service, 'find').returns(servicesMock);
-        controller.saveZkConfigs(yarnData);
-        
expect(controller.saveConfigsBatch.firstCall.args[0].someProperty('properties.yarn-site')).to.equal(item.shouldYarnSiteBeModified);
-        
expect(controller.saveConfigsBatch.firstCall.args[0].someProperty('properties_attributes.yarn-site')).to.equal(item.shouldYarnSiteBeModified);
-        App.get.restore();
-        App.Service.find.restore();
+
+        beforeEach(function () {
+          sinon.stub(App, 
'get').withArgs('isHadoop22Stack').returns(item.isHadoop22Stack).
+            withArgs('isRMHaEnabled').returns(item.isRMHaEnabled);
+          sinon.stub(App.Service, 'find').returns(servicesMock);
+          controller.saveZkConfigs(yarnData);
+        });
+
+        afterEach(function () {
+          App.get.restore();
+          App.Service.find.restore();
+        });
+
+        it('some properties.yarn-site = true (' + 
item.shouldYarnSiteBeModified + ')', function () {
+          
expect(controller.saveConfigsBatch.firstCall.args[0].someProperty('properties.yarn-site')).to.equal(item.shouldYarnSiteBeModified);
+        });
+
+        it('some properties_attributes.yarn-site = true (' + 
item.shouldYarnSiteBeModified + ')', function () {
+          
expect(controller.saveConfigsBatch.firstCall.args[0].someProperty('properties_attributes.yarn-site')).to.equal(item.shouldYarnSiteBeModified);
+        });
+
       });
     });
 
@@ -1346,24 +1376,38 @@ describe('App.MainHostDetailsController', function () {
     ];
 
     tests.forEach(function(test) {
-      it(test.m, function() {
-        if (test.appGetterStubs) {
-          Em.keys(test.appGetterStubs).forEach(function(key) {
-            sinon.stub(App, 
'get').withArgs(key).returns(test.appGetterStubs[key]);
-          });
-        }
-        if (test.ctrlStubs) {
-          var stub = sinon.stub(controller, 'get');
-          Em.keys(test.ctrlStubs).forEach(function(key) {
-            stub.withArgs(key).returns(test.ctrlStubs[key]);
-          });
-        }
-        sinon.stub(App.HostComponent, 'find').returns(test.hostComponentModel);
-        controller.updateZkConfigs(test.configs);
-        expect(test.configs).to.be.eql(test.e.configs);
-        if (test.ctrlStubs) controller.get.restore();
-        if (test.appGetterStubs) App.get.restore();
-        App.HostComponent.find.restore();
+      describe(test.m, function() {
+
+        beforeEach(function() {
+          if (test.appGetterStubs) {
+            Em.keys(test.appGetterStubs).forEach(function(key) {
+              sinon.stub(App, 
'get').withArgs(key).returns(test.appGetterStubs[key]);
+            });
+          }
+          if (test.ctrlStubs) {
+            var stub = sinon.stub(controller, 'get');
+            Em.keys(test.ctrlStubs).forEach(function(key) {
+              stub.withArgs(key).returns(test.ctrlStubs[key]);
+            });
+          }
+          sinon.stub(App.HostComponent, 
'find').returns(test.hostComponentModel);
+          controller.updateZkConfigs(test.configs);
+        });
+
+        afterEach(function () {
+          if (test.ctrlStubs) {
+            controller.get.restore();
+          }
+          if (test.appGetterStubs) {
+            App.get.restore();
+          }
+          App.HostComponent.find.restore();
+        });
+
+        it('configs are mapped correctly', function () {
+          expect(test.configs).to.be.eql(test.e.configs);
+        });
+
       });
     });
   });
@@ -1445,12 +1489,23 @@ describe('App.MainHostDetailsController', function () {
       controller.runDecommission('host1', 'YARN');
       expect(controller.doDecommission.calledWith('host1', 'YARN', 
"RESOURCEMANAGER", "NODEMANAGER")).to.be.true;
     });
-    it('HBASE service', function () {
-      sinon.stub(controller, 'warnBeforeDecommission', Em.K);
-      controller.runDecommission('host1', 'HBASE');
-      expect(controller.warnBeforeDecommission.calledWith('host1')).to.be.true;
-      controller.warnBeforeDecommission.restore();
+
+    describe('HBASE service', function () {
+
+      beforeEach(function () {
+        sinon.stub(controller, 'warnBeforeDecommission', Em.K);
+      });
+
+      afterEach(function () {
+        controller.warnBeforeDecommission.restore();
+      });
+      it('warnBeforeDecommission is called with valid arguments', function () {
+        controller.runDecommission('host1', 'HBASE');
+        
expect(controller.warnBeforeDecommission.calledWith('host1')).to.be.true;
+      });
+
     });
+
   });
 
   describe('#runRecommission()', function () {
@@ -1934,14 +1989,27 @@ describe('App.MainHostDetailsController', function () {
       toDecommissionComponents: []
     };
 
+    beforeEach(function () {
+      this.stub = sinon.stub(App.HostComponent, 'find').returns([{
+        id: 'TASKTRACKER_host1',
+        componentName: 'TASKTRACKER'
+      }]);;
+    });
+
+    afterEach(function () {
+      this.stub.restore();
+    });
+
     it('content.hostComponents is null', function () {
       controller.set('content', {hostComponents: null});
       expect(controller.getHostComponentsInfo()).to.eql(result);
     });
+
     it('content.hostComponents is empty', function () {
       controller.set('content', {hostComponents: []});
       expect(controller.getHostComponentsInfo()).to.eql(result);
     });
+
     it('content.hostComponents has ZOOKEEPER_SERVER', function () {
       App.HostComponent.find().clear();
       controller.set('content', {
@@ -1953,15 +2021,8 @@ describe('App.MainHostDetailsController', function () {
       });
       expect(controller.getHostComponentsInfo().zkServerInstalled).to.be.true;
     });
+
     it('content.hostComponents has last component', function () {
-      sinon.stub(App.HostComponent, 'find', function () {
-        return [
-          {
-            id: 'TASKTRACKER_host1',
-            componentName: 'TASKTRACKER'
-          }
-        ];
-      });
       controller.set('content', {
         hostComponents: [Em.Object.create({
           componentName: 'TASKTRACKER',
@@ -1971,17 +2032,9 @@ describe('App.MainHostDetailsController', function () {
         })]
       });
       
expect(controller.getHostComponentsInfo().lastComponents).to.eql(['TaskTracker']);
-      App.HostComponent.find.restore();
     });
+
     it('content.hostComponents has master non-deletable component', function 
() {
-      sinon.stub(App.HostComponent, 'find', function () {
-        return [
-          {
-            id: 'TASKTRACKER_host1',
-            componentName: 'TASKTRACKER'
-          }
-        ];
-      });
       controller.set('content', {
         hostComponents: [Em.Object.create({
           componentName: 'TASKTRACKER',
@@ -1993,17 +2046,9 @@ describe('App.MainHostDetailsController', function () {
       });
       
expect(controller.getHostComponentsInfo().masterComponents).to.eql(['ZK1']);
       
expect(controller.getHostComponentsInfo().nonDeletableComponents).to.eql(['ZK1']);
-      App.HostComponent.find.restore();
     });
+
     it('content.hostComponents has running component', function () {
-      sinon.stub(App.HostComponent, 'find', function () {
-        return [
-          {
-            id: 'TASKTRACKER_host1',
-            componentName: 'TASKTRACKER'
-          }
-        ];
-      });
       controller.set('content', {
         hostComponents: [Em.Object.create({
           componentName: 'TASKTRACKER',
@@ -2013,17 +2058,9 @@ describe('App.MainHostDetailsController', function () {
         })]
       });
       
expect(controller.getHostComponentsInfo().runningComponents).to.eql(['ZK1']);
-      App.HostComponent.find.restore();
     });
+
     it('content.hostComponents has non-deletable component', function () {
-      sinon.stub(App.HostComponent, 'find', function () {
-        return [
-          {
-            id: 'TASKTRACKER_host1',
-            componentName: 'TASKTRACKER'
-          }
-        ];
-      });
       controller.set('content', {
         hostComponents: [Em.Object.create({
           componentName: 'TASKTRACKER',
@@ -2033,17 +2070,9 @@ describe('App.MainHostDetailsController', function () {
         })]
       });
       
expect(controller.getHostComponentsInfo().nonDeletableComponents).to.eql(['ZK1']);
-      App.HostComponent.find.restore();
     });
+
     it('content.hostComponents has component with UNKNOWN state', function () {
-      sinon.stub(App.HostComponent, 'find', function () {
-        return [
-          {
-            id: 'TASKTRACKER_host1',
-            componentName: 'TASKTRACKER'
-          }
-        ];
-      });
       controller.set('content', {
         hostComponents: [Em.Object.create({
           componentName: 'TASKTRACKER',
@@ -2053,8 +2082,8 @@ describe('App.MainHostDetailsController', function () {
         })]
       });
       
expect(controller.getHostComponentsInfo().unknownComponents).to.eql(['ZK1']);
-      App.HostComponent.find.restore();
     });
+
   });
 
   describe('#validateAndDeleteHost()', function () {
@@ -2171,16 +2200,22 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#confirmDeleteHost()', function () {
-    it('Popup should be displayed', function () {
+
+    beforeEach(function () {
       sinon.spy(App.ModalPopup, "show");
       sinon.stub(controller, 'doDeleteHost');
+    });
+
+    afterEach(function () {
+      App.ModalPopup.show.restore();
+      controller.doDeleteHost.restore();
+    });
 
+    it('Popup should be displayed', function () {
       var popup = controller.confirmDeleteHost({toDecommissionComponents:[]});
       expect(App.ModalPopup.show.calledOnce).to.be.true;
       popup.onPrimary();
       expect(controller.doDeleteHost.calledOnce).to.be.true;
-      App.ModalPopup.show.restore();
-      controller.doDeleteHost.restore();
     });
   });
 
@@ -2550,11 +2585,18 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#refreshComponentConfigsSuccessCallback()', function () {
-    it('call showBackgroundOperationsPopup', function () {
+
+    beforeEach(function () {
       sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
+    });
+
+    afterEach(function () {
+      controller.showBackgroundOperationsPopup.restore();
+    });
+
+    it('call showBackgroundOperationsPopup', function () {
       controller.refreshComponentConfigsSuccessCallback();
       expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
-      controller.showBackgroundOperationsPopup.restore();
     });
   });
 
@@ -2562,24 +2604,25 @@ describe('App.MainHostDetailsController', function () {
     beforeEach(function () {
       sinon.stub(controller, 'removeObserver');
       sinon.stub(controller, 'loadConfigs');
-      sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
-        callback();
-      });
+      sinon.stub(controller, 'isServiceMetricsLoaded', Em.clb);
+      this.stub = sinon.stub(App.router, 'get');
     });
     afterEach(function () {
       controller.loadConfigs.restore();
       controller.removeObserver.restore();
       controller.isServiceMetricsLoaded.restore();
-      App.router.get.restore();
+      this.stub.restore();
     });
+
     it('No operations of ZOOKEEPER_SERVER', function () {
-      sinon.stub(App.router, 
'get').withArgs('backgroundOperationsController.services').returns([]);
+      
this.stub.withArgs('backgroundOperationsController.services').returns([]);
       controller.checkZkConfigs();
       expect(controller.removeObserver.called).to.be.false;
       expect(controller.loadConfigs.called).to.be.false;
     });
+
     it('Operation of ZOOKEEPER_SERVER running', function () {
-      sinon.stub(App.router, 
'get').withArgs('backgroundOperationsController.services').returns([Em.Object.create({
+      
this.stub.withArgs('backgroundOperationsController.services').returns([Em.Object.create({
         id: 1,
         isRunning: true
       })]);
@@ -2588,17 +2631,28 @@ describe('App.MainHostDetailsController', function () {
       expect(controller.removeObserver.called).to.be.false;
       expect(controller.loadConfigs.called).to.be.false;
     });
-    it('Operation of ZOOKEEPER_SERVER finished', function () {
-      sinon.stub(App.router, 
'get').withArgs('backgroundOperationsController.services').returns([Em.Object.create({
-        id: 1
-      })]);
-      var clock = sinon.useFakeTimers();
-      controller.set('zkRequestId', 1);
-      controller.checkZkConfigs();
-      
expect(controller.removeObserver.calledWith('App.router.backgroundOperationsController.serviceTimestamp',
 controller, controller.checkZkConfigs)).to.be.true;
-      clock.tick(App.get('componentsUpdateInterval'));
-      expect(controller.loadConfigs.calledOnce).to.be.true;
-      clock.restore();
+
+    describe('Operation of ZOOKEEPER_SERVER finished', function () {
+
+      beforeEach(function () {
+        
this.stub.withArgs('backgroundOperationsController.services').returns([Em.Object.create({
+          id: 1
+        })]);
+        this.clock = sinon.useFakeTimers();
+        controller.set('zkRequestId', 1);
+        controller.checkZkConfigs();
+      });
+
+      afterEach(function () {
+        this.clock.restore();
+      });
+
+      it('loadConfigs is called after `componentsUpdateInterval`', function () 
{
+        
expect(controller.removeObserver.calledWith('App.router.backgroundOperationsController.serviceTimestamp',
 controller, controller.checkZkConfigs)).to.be.true;
+        this.clock.tick(App.get('componentsUpdateInterval'));
+        expect(controller.loadConfigs.calledOnce).to.be.true;
+      });
+
     });
   });
 
@@ -2613,21 +2667,15 @@ describe('App.MainHostDetailsController', function () {
     beforeEach(function () {
       sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
       sinon.stub(controller, 'mimicWorkStatusChange', Em.K);
+      sinon.stub(App, 'get').withArgs('testMode').returns(false);
     });
     afterEach(function () {
       controller.mimicWorkStatusChange.restore();
       controller.showBackgroundOperationsPopup.restore();
+      App.get.restore();
     });
-    it('testMode is true', function () {
-      App.set('testMode', true);
 
-      controller.installComponentSuccessCallback({}, {}, {component: "COMP"});
-      expect(controller.mimicWorkStatusChange.calledWith("COMP", 
App.HostComponentStatus.installing, 
App.HostComponentStatus.stopped)).to.be.true;
-      expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
-    });
     it('testMode is false', function () {
-      App.set('testMode', false);
-
       controller.installComponentSuccessCallback({}, {}, {component: "COMP"});
       expect(controller.mimicWorkStatusChange.called).to.be.false;
       expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
@@ -2635,21 +2683,35 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#showHbaseActiveWarning()', function () {
-    it('popup should be displayed', function () {
+
+    beforeEach(function () {
       sinon.spy(App.ModalPopup, "show");
-      var popup = controller.showHbaseActiveWarning(Em.Object.create({service: 
{}}));
-      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+
+    afterEach(function () {
       App.ModalPopup.show.restore();
     });
+
+    it('popup should be displayed', function () {
+      controller.showHbaseActiveWarning(Em.Object.create({service: {}}));
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
   });
 
   describe('#updateHost()', function () {
-    it('popup should be displayed', function () {
+
+    beforeEach(function () {
       sinon.stub(batchUtils, "infoPassiveState", Em.K);
+    });
+
+    afterEach(function () {
+      batchUtils.infoPassiveState.restore();
+    });
+
+    it('popup should be displayed', function () {
       controller.updateHost({}, {}, {passive_state: 'state'});
       expect(controller.get('content.passiveState')).to.equal('state');
       expect(batchUtils.infoPassiveState.calledWith('state')).to.be.true;
-      batchUtils.infoPassiveState.restore();
     });
   });
 
@@ -2671,16 +2733,24 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#updateHostComponent()', function () {
-    it('popup should be displayed', function () {
+
+    var params = {
+      component: Em.Object.create(),
+      passive_state: 'state'
+    };
+
+    beforeEach(function () {
       sinon.stub(batchUtils, "infoPassiveState", Em.K);
-      var params = {
-        component: Em.Object.create(),
-        passive_state: 'state'
-      };
+    });
+
+    afterEach(function () {
+      batchUtils.infoPassiveState.restore();
+    });
+
+    it('popup should be displayed', function () {
       controller.updateHostComponent({}, {}, params);
       expect(params.component.get('passiveState')).to.equal('state');
       expect(batchUtils.infoPassiveState.calledWith('state')).to.be.true;
-      batchUtils.infoPassiveState.restore();
     });
   });
 
@@ -2833,40 +2903,69 @@ describe('App.MainHostDetailsController', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        sinon.stub(controller, 'checkComponentDependencies', function 
(componentName, params) {
-          return item.dependencies[componentName];
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(controller, 'checkComponentDependencies', function 
(componentName, params) {
+            return item.dependencies[componentName];
+          });
+          controller.installClients({
+            context: item.context
+          });
+        });
+
+        it('getSecurityType is ' + (item.getKDCSessionStateCalled ? '' : 
'not') + ' called', function() {
+          
expect(App.get('router.mainAdminKerberosController').getSecurityType.calledOnce).to.equal(item.getKDCSessionStateCalled);
+        });
+
+        it('getKDCSessionState is ' + (item.getKDCSessionStateCalled ? '' : 
'not') + ' called', function() {
+          
expect(App.get('router.mainAdminKerberosController').getKDCSessionState.calledOnce).to.equal(item.getKDCSessionStateCalled);
+        });
+
+        it('sendComponentCommand is ' + (item.sendComponentCommandCalled ? '' 
: 'not') + ' called', function() {
+          
expect(controller.sendComponentCommand.calledOnce).to.equal(item.sendComponentCommandCalled);
         });
-        controller.installClients({
-          context: item.context
+
+        it('showAlertPopup is ' + (item.showAlertPopupCalled ? '' : 'not') + ' 
called', function() {
+          
expect(App.showAlertPopup.calledOnce).to.equal(item.showAlertPopupCalled);
         });
-        
expect(App.get('router.mainAdminKerberosController').getSecurityType.calledOnce).to.equal(item.getKDCSessionStateCalled);
-        
expect(App.get('router.mainAdminKerberosController').getKDCSessionState.calledOnce).to.equal(item.getKDCSessionStateCalled);
-        
expect(controller.sendComponentCommand.calledOnce).to.equal(item.sendComponentCommandCalled);
-        
expect(App.showAlertPopup.calledOnce).to.equal(item.showAlertPopupCalled);
+
       });
     });
   });
 
   describe("#executeCustomCommandSuccessCallback()", function () {
-    it("BO popup should be shown", function () {
-      var mock = {
-        showPopup: Em.K
-      };
-      sinon.stub(App.router, 'get').returns(mock);
-      sinon.spy(mock, 'showPopup');
-      var data = {
+
+    var data;
+    var mock;
+
+    beforeEach(function () {
+      data = {
         Requests: {
           id: 1
         }
       };
+      mock = {
+        showPopup: Em.K
+      };
+      sinon.stub(App.router, 'get').returns(mock);
+      sinon.spy(mock, 'showPopup');
       controller.executeCustomCommandSuccessCallback(data, {}, {});
+    });
 
-      
expect(App.router.get.calledWith('backgroundOperationsController')).to.be.true;
-      expect(mock.showPopup.calledOnce).to.be.true;
+    afterEach(function () {
       App.router.get.restore();
       mock.showPopup.restore();
     });
+
+    it('App.router.get is called with `backgroundOperationsController`', 
function () {
+      
expect(App.router.get.calledWith('backgroundOperationsController')).to.be.true;
+    });
+
+    it('showPopup is called once', function () {
+      expect(mock.showPopup.calledOnce).to.be.true;
+    });
+
   });
 
   describe("#executeCustomCommandErrorCallback()", function () {
@@ -2893,7 +2992,7 @@ describe('App.MainHostDetailsController', function () {
       
expect(App.showAlertPopup.calledWith(Em.I18n.t('services.service.actions.run.executeCustomCommand.error'),
 
Em.I18n.t('services.service.actions.run.executeCustomCommand.error'))).to.be.true;
       expect($.parseJSON.called).to.be.false;
     });
-    it("data empty", function () {
+    it("data empty (2)", function () {
       var data = {
         responseText: "test"
       };
@@ -2936,8 +3035,9 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe("#deleteHostSuccessCallback", function () {
-    it("call updateHost", function () {
-      var mock = {
+    var mock;
+    beforeEach(function () {
+      mock = {
         updateHost: function (callback) {
           callback();
         },
@@ -2948,18 +3048,11 @@ describe('App.MainHostDetailsController', function () {
       sinon.spy(mock, 'getAllHostNames');
       sinon.stub(controller, 'loadConfigs', Em.K);
       sinon.stub(App.router, 'transitionTo', Em.K);
-      sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
-        callback();
-      });
-
+      sinon.stub(controller, 'isServiceMetricsLoaded', Em.clb);
       controller.deleteHostSuccessCallback();
-      expect(App.router.get.calledWith('updateController')).to.be.true;
-      expect(mock.updateHost.calledOnce).to.be.true;
-      expect(controller.loadConfigs.called).to.be.false;
-      expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
-      expect(App.router.get.calledWith('clusterController')).to.be.true;
-      expect(mock.getAllHostNames.calledOnce).to.be.true;
+    });
 
+    afterEach(function () {
       App.router.get.restore();
       mock.updateHost.restore();
       mock.getAllHostNames.restore();
@@ -2967,25 +3060,51 @@ describe('App.MainHostDetailsController', function () {
       controller.isServiceMetricsLoaded.restore();
       App.router.transitionTo.restore();
     });
+
+    it('updateController is used', function () {
+      expect(App.router.get.calledWith('updateController')).to.be.true;
+    });
+    it('updateHost is called once', function () {
+      expect(mock.updateHost.calledOnce).to.be.true;
+    });
+    it('loadConfigs is not called', function () {
+      expect(controller.loadConfigs.called).to.be.false;
+    });
+    it('user is moved to the hosts', function () {
+      expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
+    });
+    it('clusterController is used', function () {
+      expect(App.router.get.calledWith('clusterController')).to.be.true;
+    });
+    it('getAllHostNames is called once', function () {
+      expect(mock.getAllHostNames.calledOnce).to.be.true;
+    });
   });
 
   describe("#deleteHostErrorCallback", function () {
-    it("call defaultErrorHandler", function () {
+
+    beforeEach(function () {
       sinon.stub(controller, 'loadConfigs', Em.K);
       sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
-      sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
-        callback();
-      });
+      sinon.stub(controller, 'isServiceMetricsLoaded', Em.clb);
       controller.deleteHostErrorCallback({
         status: 'status',
         statusText: "statusText"
       }, 'textStatus', 'errorThrown', {url: 'url'});
-      expect(controller.loadConfigs.calledOnce).to.be.true;
-      expect(App.ajax.defaultErrorHandler.calledOnce).to.be.true;
+    });
+
+    afterEach(function () {
       App.ajax.defaultErrorHandler.restore();
       controller.loadConfigs.restore();
       controller.isServiceMetricsLoaded.restore();
     });
+
+    it('loadConfigs is called once', function () {
+      expect(controller.loadConfigs.calledOnce).to.be.true;
+    });
+    it('defaultErrorHandler is called once', function () {
+      expect(App.ajax.defaultErrorHandler.calledOnce).to.be.true;
+    });
   });
 
   describe('#installVersionConfirmation()', function () {
@@ -3157,19 +3276,33 @@ describe('App.MainHostDetailsController', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        Em.keys(item.input).forEach(function (key) {
-          controller.set(key, item.input[key]);
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          Em.keys(item.input).forEach(function (key) {
+            controller.set(key, item.input[key]);
+          });
+          this.hostsMap = controller.getHiveHosts().toArray();
+          this.expectedHosts = this.hostsMap.filter(function(hostInfo) {
+            return ['WEBHCAT_SERVER', 
'HIVE_METASTORE'].contains(hostInfo.component) && hostInfo.isInstalled === true;
+          }).mapProperty('hostName').uniq();
+        });
+
+        it(JSON.stringify(item.hiveHosts) + ' are in the list', function () {
+          expect(this.expectedHosts).to.include.same.members(item.hiveHosts);
+        });
+        it('hiveMetastoreHost is empty', function () {
+          expect(controller.get('hiveMetastoreHost')).to.be.empty;
+        });
+        it('webhcatServerHost is empty', function () {
+          expect(controller.get('webhcatServerHost')).to.be.empty;
+        });
+        it('fromDeleteHost is false', function () {
+          expect(controller.get('fromDeleteHost')).to.be.false;
+        });
+        it('deleteHiveMetaStore is false', function () {
+          expect(controller.get('deleteHiveMetaStore')).to.be.false;
         });
-        var hostsMap = controller.getHiveHosts().toArray();
-        var expectedHosts = hostsMap.filter(function(hostInfo) {
-          return ['WEBHCAT_SERVER', 
'HIVE_METASTORE'].contains(hostInfo.component) && hostInfo.isInstalled === true;
-        }).mapProperty('hostName').uniq();
-        expect(expectedHosts).to.include.same.members(item.hiveHosts);
-        expect(controller.get('hiveMetastoreHost')).to.be.empty;
-        expect(controller.get('webhcatServerHost')).to.be.empty;
-        expect(controller.get('fromDeleteHost')).to.be.false;
-        expect(controller.get('deleteHiveMetaStore')).to.be.false;
       });
     });
 
@@ -3225,9 +3358,8 @@ describe('App.MainHostDetailsController', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        controller.set('rangerKMSServerHost', item.hostToInstall);
-        sinon.stub(controller, 
'getRangerKMSServerHosts').returns(item.kmsHosts);
+      describe(item.title, function () {
+
         var data = {
           items: [
             {
@@ -3244,8 +3376,16 @@ describe('App.MainHostDetailsController', function () {
             }
           ]
         };
-        controller.onLoadRangerConfigs(data);
-        expect(controller.saveConfigsBatch.calledWith(item.result, 
'RANGER_KMS_SERVER', item.hostToInstall)).to.be.true;
+
+        beforeEach(function () {
+          controller.set('rangerKMSServerHost', item.hostToInstall);
+          sinon.stub(controller, 
'getRangerKMSServerHosts').returns(item.kmsHosts);
+          controller.onLoadRangerConfigs(data);
+        });
+
+        it('saveConfigsBatch is called with valid arguments', function () {
+          expect(controller.saveConfigsBatch.calledWith(item.result, 
'RANGER_KMS_SERVER', item.hostToInstall)).to.be.true;
+        });
       });
     });
 
@@ -3757,26 +3897,40 @@ describe('App.MainHostDetailsController', function () {
     ];
 
     tests.forEach(function(test) {
-      it(test.m.format(inlineComponentHostInfo(test.hostComponentModel), 
test.ctrlStubs ? JSON.stringify(test.ctrlStubs) : 'None'), function() {
-        if (test.appGetterStubs) {
-          Em.keys(test.appGetterStubs).forEach(function(key) {
-            sinon.stub(App, 
'get').withArgs(key).returns(test.appGetterStubs[key]);
-          });
-        }
-        if (test.ctrlStubs) {
-          var stub = sinon.stub(controller, 'get');
-          Em.keys(test.ctrlStubs).forEach(function(key) {
-            stub.withArgs(key).returns(test.ctrlStubs[key]);
-          });
-        }
-        sinon.stub(App.HostComponent, 'find').returns(test.hostComponentModel);
-        controller.onLoadHiveConfigs(test.configs);
-        var configs = controller.saveConfigsBatch.args[0];
-        var properties = configs[0];
-        expect(properties).to.be.eql(test.e.configs);
-        if (test.ctrlStubs) controller.get.restore();
-        if (test.appGetterStubs) App.get.restore();
-        App.HostComponent.find.restore();
+      describe(test.m.format(inlineComponentHostInfo(test.hostComponentModel), 
test.ctrlStubs ? JSON.stringify(test.ctrlStubs) : 'None'), function() {
+
+        beforeEach(function () {
+          if (test.appGetterStubs) {
+            Em.keys(test.appGetterStubs).forEach(function(key) {
+              sinon.stub(App, 
'get').withArgs(key).returns(test.appGetterStubs[key]);
+            });
+          }
+          if (test.ctrlStubs) {
+            var stub = sinon.stub(controller, 'get');
+            Em.keys(test.ctrlStubs).forEach(function(key) {
+              stub.withArgs(key).returns(test.ctrlStubs[key]);
+            });
+          }
+          sinon.stub(App.HostComponent, 
'find').returns(test.hostComponentModel);
+        });
+
+        afterEach(function () {
+          if (test.ctrlStubs) {
+            controller.get.restore();
+          }
+          if (test.appGetterStubs) {
+            App.get.restore();
+          }
+          App.HostComponent.find.restore();
+        });
+
+        it('saveConfigsBatch is called with correct configs', function () {
+          controller.onLoadHiveConfigs(test.configs);
+          var configs = controller.saveConfigsBatch.args[0];
+          var properties = configs[0];
+          expect(properties).to.be.eql(test.e.configs);
+        });
+
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/service/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js 
b/ambari-web/test/controllers/main/service/add_controller_test.js
index 58f930f..1ec367e 100644
--- a/ambari-web/test/controllers/main/service/add_controller_test.js
+++ b/ambari-web/test/controllers/main/service/add_controller_test.js
@@ -150,16 +150,31 @@ describe('App.AddServiceController', function() {
 
     var message = '{0} installed, {1} selected. Installed list should be {2} 
and selected - {3}';
     tests.forEach(function(test) {
+
       var installed = test.appService.mapProperty('serviceName');
       var selected = 
test.stepCtrlContent.get('content').filterProperty('isSelected', true)
         .filterProperty('isInstalled', false).mapProperty('serviceName');
-      it(message.format(installed, selected, test.e.installed, 
test.e.selected), function() {
-        sinon.stub(App.Service, 'find').returns(test.appService);
-        addServiceController.saveServices(test.stepCtrlContent);
-        App.Service.find.restore();
-        var savedServices = 
addServiceController.setDBProperty.withArgs('services').args[0][1];
-        
expect(savedServices.selectedServices).to.have.members(test.e.selected);
-        
expect(savedServices.installedServices).to.have.members(test.e.installed);
+
+      describe(message.format(installed, selected, test.e.installed, 
test.e.selected), function() {
+
+        beforeEach(function () {
+          sinon.stub(App.Service, 'find').returns(test.appService);
+          addServiceController.saveServices(test.stepCtrlContent);
+          this.savedServices = 
addServiceController.setDBProperty.withArgs('services').args[0][1];
+        });
+
+        afterEach(function () {
+          App.Service.find.restore();
+        });
+
+        it(JSON.stringify(test.e.selected) + ' are in the selectedServices', 
function () {
+          
expect(this.savedServices.selectedServices).to.have.members(test.e.selected);
+        });
+
+        it(JSON.stringify(test.e.installed) + ' are in the installedServices', 
function () {
+          
expect(this.savedServices.installedServices).to.have.members(test.e.installed);
+        });
+
       });
     });
   });
@@ -193,10 +208,16 @@ describe('App.AddServiceController', function() {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        sinon.stub(addServiceController, 
'getDBProperty').withArgs('hosts').returns(item.hosts);
-        addServiceController.loadHosts();
-        expect(App.ajax.send.calledOnce).to.equal(item.isAjaxRequestSent);
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(addServiceController, 
'getDBProperty').withArgs('hosts').returns(item.hosts);
+          addServiceController.loadHosts();
+        });
+
+        it('request is ' + (item.isAjaxRequestSent ? '' : 'not') + ' sent', 
function () {
+          expect(App.ajax.send.calledOnce).to.equal(item.isAjaxRequestSent);
+        });
       });
     });
 
@@ -407,22 +428,40 @@ describe('App.AddServiceController', function() {
     ];
 
     tests.forEach(function(test) {
-      it(test.m, function() {
-        this.mockStackService.returns(test.appStackService);
-        this.mockService.returns(test.appService);
-        
this.mockGetDBProperty.withArgs('services').returns(test.servicesFromDB);
-        this.controller.set('serviceToInstall', test.serviceToInstall);
-        this.controller.loadServices();
-        if (!test.servicesFromDB) {
-          // verify saving to local db on first enter to the wizard
-          expect(mock.db.selectedServices).to.be.eql(test.e.selectedServices);
-          
expect(mock.db.installedServices).to.be.eql(test.e.installedServices);
-        } else {
+      describe(test.m, function() {
+
+        beforeEach(function () {
+          this.mockStackService.returns(test.appStackService);
+          this.mockService.returns(test.appService);
+          
this.mockGetDBProperty.withArgs('services').returns(test.servicesFromDB);
+          this.controller.set('serviceToInstall', test.serviceToInstall);
+          this.controller.loadServices();
+        });
+
+        if (test.servicesFromDB) {
           // verify values for App.StackService
-          expect(test.appStackService.filterProperty('isSelected', 
true).mapProperty('serviceName')).to.be.eql(test.e.selectedServices);
-          expect(test.appStackService.filterProperty('isInstalled', 
true).mapProperty('serviceName')).to.be.eql(test.e.installedServices);
+          it(JSON.stringify(test.e.selectedServices) + ' are selected', 
function () {
+            expect(test.appStackService.filterProperty('isSelected', 
true).mapProperty('serviceName')).to.be.eql(test.e.selectedServices);
+          });
+          it(JSON.stringify(test.e.installedServices) + ' are installed', 
function () {
+            expect(test.appStackService.filterProperty('isInstalled', 
true).mapProperty('serviceName')).to.be.eql(test.e.installedServices);
+          });
+        }
+        else {
+          // verify saving to local db on first enter to the wizard
+          it('selectedServices are saced', function () {
+            
expect(mock.db.selectedServices).to.be.eql(test.e.selectedServices);
+          });
+          it('installedServices are saved', function () {
+            
expect(mock.db.installedServices).to.be.eql(test.e.installedServices);
+          });
+
         }
-        expect(this.controller.get('serviceToInstall')).to.be.null;
+
+        it('serviceToInstall is null', function () {
+          expect(this.controller.get('serviceToInstall')).to.be.null;
+        });
+
       });
     }, this);
   });
@@ -461,11 +500,21 @@ describe('App.AddServiceController', function() {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        sinon.stub(App, 
'get').withArgs('isKerberosEnabled').returns(item.securityEnabled);
-        addServiceController.checkSecurityStatus();
-        
expect(addServiceController.get('skipConfigureIdentitiesStep')).to.equal(item.skipConfigureIdentitiesStep);
-        expect(addServiceController.get('isStepDisabled').findProperty('step', 
5).get('value')).to.equal(item.isStep5Disabled);
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(App, 
'get').withArgs('isKerberosEnabled').returns(item.securityEnabled);
+          addServiceController.checkSecurityStatus();
+        });
+
+        it('skipConfigureIdentitiesStep is ' + 
item.skipConfigureIdentitiesStep, function () {
+          
expect(addServiceController.get('skipConfigureIdentitiesStep')).to.equal(item.skipConfigureIdentitiesStep);
+        });
+
+        it('step 5 is ' + (item.isStep5Disabled ? 'disabved' : 'enabled'), 
function () {
+          
expect(addServiceController.get('isStepDisabled').findProperty('step', 
5).get('value')).to.equal(item.isStep5Disabled);
+        });
+
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js 
b/ambari-web/test/controllers/main/service/info/config_test.js
index ba8f1d3..60aa8d6 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -134,6 +134,7 @@ describe("App.MainServiceInfoConfigsController", function 
() {
         return "hash"
       });
     });
+
     afterEach(function () {
       mainServiceInfoConfigsController.get.restore();
       mainServiceInfoConfigsController.restartServicePopup.restore();
@@ -142,24 +143,45 @@ describe("App.MainServiceInfoConfigsController", function 
() {
 
     tests.forEach(function (t) {
       t.results.forEach(function (r) {
-        it(t.m + " " + r.method + " " + r.field, function () {
-          if (t.callback) {
-            t.callback = sinon.stub();
-          }
-          if (t.transitionCallback) {
-            t.transitionCallback = sinon.stub();
-          }
-          mainServiceInfoConfigsController.showSavePopup(t.transitionCallback, 
t.callback)[t.action]();
+        describe(t.m + " " + r.method + " " + r.field, function () {
+
+          beforeEach(function () {
+            if (t.callback) {
+              t.callback = sinon.stub();
+            }
+            if (t.transitionCallback) {
+              t.transitionCallback = sinon.stub();
+            }
+            
mainServiceInfoConfigsController.showSavePopup(t.transitionCallback, 
t.callback)[t.action]();
+          });
+
+
           if (r.method) {
             if (r.method === 'callback') {
-              expect(t.callback.calledOnce).to.equal(r.called);
-            } else if (r.method === 'transitionCallback') {
-              expect(t.transitionCallback.calledOnce).to.equal(r.called);
-            } else {
-              
expect(mainServiceInfoConfigsController[r.method].calledOnce).to.equal(r.called);
+              it('callback is ' + (r.called ? '' : 'not') + ' called once', 
function () {
+                expect(t.callback.calledOnce).to.equal(r.called);
+              });
+            }
+            else {
+              if (r.method === 'transitionCallback') {
+                it('transitionCallback is ' + (r.called ? '' : 'not') + ' 
called once', function () {
+                  expect(t.transitionCallback.calledOnce).to.equal(r.called);
+                });
+              }
+              else {
+                it(r.method + ' is ' + (r.called ? '' : 'not') + ' called 
once', function () {
+                  
expect(mainServiceInfoConfigsController[r.method].calledOnce).to.equal(r.called);
+                });
+              }
+            }
+          }
+          else {
+            if (r.field) {
+              it(r.field + ' is equal to ' + r.value, function () {
+                
expect(mainServiceInfoConfigsController.get(r.field)).to.equal(r.value);
+              });
+
             }
-          } else if (r.field) {
-            
expect(mainServiceInfoConfigsController.get(r.field)).to.equal(r.value);
           }
         }, this);
       });
@@ -324,17 +346,21 @@ describe("App.MainServiceInfoConfigsController", function 
() {
   });
 
   describe("#restartAllStaleConfigComponents", function () {
+
     beforeEach(function () {
       sinon.stub(batchUtils, "restartAllServiceHostComponents", Em.K);
     });
+
     afterEach(function () {
       batchUtils.restartAllServiceHostComponents.restore();
     });
+
     it("trigger restartAllServiceHostComponents", function () {
       
mainServiceInfoConfigsController.restartAllStaleConfigComponents().onPrimary();
       
expect(batchUtils.restartAllServiceHostComponents.calledOnce).to.equal(true);
     });
-    it("trigger check last check point warning before triggering 
restartAllServiceHostComponents", function () {
+
+    describe("trigger check last check point warning before triggering 
restartAllServiceHostComponents", function () {
       var mainConfigsControllerHdfsStarted = 
App.MainServiceInfoConfigsController.create({
         content: {
           serviceName: "HDFS",
@@ -349,20 +375,30 @@ describe("App.MainServiceInfoConfigsController", function 
() {
         }
       });
       var mainServiceItemController = App.MainServiceItemController.create({});
-      sinon.stub(mainServiceItemController, 'checkNnLastCheckpointTime', 
function() {
-        return true;
+
+      beforeEach(function () {
+        sinon.stub(mainServiceItemController, 'checkNnLastCheckpointTime', 
function() {
+          return true;
+        });
+        sinon.stub(App.router, 'get', function(k) {
+          if ('mainServiceItemController' === k) {
+            return mainServiceItemController;
+          }
+          return Em.get(App.router, k);
+        });
+        mainConfigsControllerHdfsStarted.restartAllStaleConfigComponents();
       });
-      sinon.stub(App.router, 'get', function(k) {
-        if ('mainServiceItemController' === k) {
-          return mainServiceItemController;
-        }
-        return Em.get(App.router, k);
+
+      afterEach(function () {
+        mainServiceItemController.checkNnLastCheckpointTime.restore();
+        App.router.get.restore();
+      });
+
+      it('checkNnLastCheckpointTime is called once', function () {
+        
expect(mainServiceItemController.checkNnLastCheckpointTime.calledOnce).to.equal(true);
       });
 
-      mainConfigsControllerHdfsStarted.restartAllStaleConfigComponents();
-      
expect(mainServiceItemController.checkNnLastCheckpointTime.calledOnce).to.equal(true);
-      mainServiceItemController.checkNnLastCheckpointTime.restore();
-      App.router.get.restore();
+
     });
   });
 
@@ -713,10 +749,10 @@ describe("App.MainServiceInfoConfigsController", function 
() {
     it("expect that serviceConfig.compareConfigs will be getComparisonConfig", 
function() {
       
expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty:
 true}, {})).to.eql({compareConfigs: ["compConfig"], isUserProperty: true, 
isComparison: true, hasCompareDiffs: true});
     });
-    it("expect that serviceConfig.compareConfigs will be getComparisonConfig", 
function() {
+    it("expect that serviceConfig.compareConfigs will be getComparisonConfig 
(2)", function() {
       
expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable:
 true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true, 
isComparison: true, hasCompareDiffs: true});
     });
-    it("expect that serviceConfig.compareConfigs will be getComparisonConfig", 
function() {
+    it("expect that serviceConfig.compareConfigs will be getComparisonConfig 
(3)", function() {
       
expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable:
 true, isMock: true}, {})).to.eql({compareConfigs: ["compConfig"], 
isReconfigurable: true, isMock: true, isComparison: true, hasCompareDiffs: 
true});
     });
     it("property was created during upgrade and have no comparison, compare 
with 'Undefined' value should be created", function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/item_test.js 
b/ambari-web/test/controllers/main/service/item_test.js
index 8794661..4be23c9 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -107,15 +107,27 @@ describe('App.MainServiceItemController', function () {
     ];
 
     tests.forEach(function (test) {
-      it(test.m, function () {
-        sinon.stub(App.router, 'get', function(k) {
-          if ('backgroundOperationsController.services' === k) return 
test.backgroundOperationsController.services;
-          return Em.get(App.router, k);
+      describe(test.m, function () {
+
+        var mainServiceItemController;
+
+        beforeEach(function () {
+          sinon.stub(App.router, 'get', function(k) {
+            if ('backgroundOperationsController.services' === k) return 
test.backgroundOperationsController.services;
+            return Em.get(App.router, k);
+          });
+          mainServiceItemController = 
App.MainServiceItemController.create({content: {serviceName: 
test.serviceController.serviceName}});
+          mainServiceItemController.setStartStopState();
+        });
+
+        afterEach(function () {
+          App.router.get.restore();
+        });
+
+        it('isPending is ' + test.isPending, function () {
+          
expect(mainServiceItemController.get('isPending')).to.equal(test.isPending);
         });
-        var mainServiceItemController = 
App.MainServiceItemController.create({content: {serviceName: 
test.serviceController.serviceName}});
-        mainServiceItemController.setStartStopState();
-        App.router.get.restore();
-        
expect(mainServiceItemController.get('isPending')).to.equal(test.isPending);
+
       });
     })
   });
@@ -141,34 +153,41 @@ describe('App.MainServiceItemController', function () {
     ];
 
     tests.forEach(function (test) {
-      var reassignMasterController = 
App.ReassignMasterController.create({currentStep: ''});
+      describe(test.m, function () {
 
-      beforeEach(function () {
-        sinon.stub(reassignMasterController, 'saveComponentToReassign', Em.K);
-        sinon.stub(reassignMasterController, 'setCurrentStep', Em.K);
-      });
+        var reassignMasterController = 
App.ReassignMasterController.create({currentStep: ''});
 
-      afterEach(function () {
-        reassignMasterController.saveComponentToReassign.restore();
-        reassignMasterController.setCurrentStep.restore();
-      });
+        beforeEach(function () {
+          sinon.stub(reassignMasterController, 'saveComponentToReassign', 
Em.K);
+          sinon.stub(reassignMasterController, 'setCurrentStep', Em.K);
+          sinon.stub(App.router, 'transitionTo', Em.K);
+          var mainServiceItemController = 
App.MainServiceItemController.create({});
+          sinon.stub(App.HostComponent, 'find', function() {
+            return test.host_components
+          });
+          sinon.stub(App.router, 'get', function(k) {
+            if ('reassignMasterController' === k) return 
reassignMasterController;
+            return Em.get(App.router, k);
+          });
+          mainServiceItemController.reassignMaster(test.componentName);
+        });
 
-      it(test.m, function () {
-        sinon.stub(App.router, 'transitionTo', Em.K);
-        var mainServiceItemController = 
App.MainServiceItemController.create({});
-        sinon.stub(App.HostComponent, 'find', function() {
-          return test.host_components
+        afterEach(function () {
+          reassignMasterController.saveComponentToReassign.restore();
+          reassignMasterController.setCurrentStep.restore();
+          App.HostComponent.find.restore();
+          App.router.transitionTo.restore();
+          App.router.get.restore();
         });
-        sinon.stub(App.router, 'get', function(k) {
-          if ('reassignMasterController' === k) return 
reassignMasterController;
-          return Em.get(App.router, k);
+
+        it('saveComponentToReassign is ' + (test.result ? '' : 'not') + ' 
called once', function () {
+          
expect(reassignMasterController.saveComponentToReassign.calledOnce).to.equal(test.result);
         });
-        mainServiceItemController.reassignMaster(test.componentName);
-        
expect(reassignMasterController.saveComponentToReassign.calledOnce).to.equal(test.result);
-        
expect(reassignMasterController.setCurrentStep.calledOnce).to.equal(test.result);
-        App.HostComponent.find.restore();
-        App.router.transitionTo.restore();
-        App.router.get.restore();
+
+        it('setCurrentStep is ' + (test.result ? '' : 'not') + ' called once', 
function () {
+          
expect(reassignMasterController.setCurrentStep.calledOnce).to.equal(test.result);
+        });
+
       });
     }, this);
   });
@@ -966,7 +985,8 @@ describe('App.MainServiceItemController', function () {
   });
 
   describe("#runRebalancer", function () {
-    it("run rebalancer", function () {
+
+    beforeEach(function () {
       sinon.stub(App.router, 'get', function(k) {
         if ('applicationController' === k) {
           return Em.Object.create({
@@ -977,15 +997,22 @@ describe('App.MainServiceItemController', function () {
         }
         return Em.get(App.router, k);
       });
+    });
+
+    afterEach(function () {
+      App.router.get.restore();
+    });
+
+    it("run rebalancer", function () {
       var mainServiceItemController = 
App.MainServiceItemController.create({content: {runRebalancer: false}});
       mainServiceItemController.runRebalancer().onPrimary();
       
expect(mainServiceItemController.get("content.runRebalancer")).to.equal(true);
-      App.router.get.restore();
     });
   });
 
   describe("#runCompaction", function () {
-    it("run compaction", function () {
+
+    beforeEach(function () {
       sinon.stub(App.router, 'get', function(k) {
         if ('applicationController' === k) {
           return Em.Object.create({
@@ -996,10 +1023,16 @@ describe('App.MainServiceItemController', function () {
         }
         return Em.get(App.router, k);
       });
+    });
+
+    afterEach(function () {
+      App.router.get.restore();
+    });
+
+    it("run compaction", function () {
       var mainServiceItemController = 
App.MainServiceItemController.create({content: {runCompaction: false}});
       mainServiceItemController.runCompaction().onPrimary();
       
expect(mainServiceItemController.get("content.runCompaction")).to.equal(true);
-      App.router.get.restore();
     });
   });
 
@@ -1049,19 +1082,35 @@ describe('App.MainServiceItemController', function () {
 
       var mainServiceItemController = 
App.MainServiceItemController.create({content: {serviceName: 
test.data.serviceName,
         displayName: test.data.displayName}});
-      beforeEach(function () {
-        mainServiceItemController.set("runSmokeTestErrorCallBack", Em.K);
-        mainServiceItemController.set("runSmokeTestSuccessCallBack", Em.K);
-      });
+      describe('send request to run smoke test for ' + test.data.serviceName, 
function () {
 
-      it('send request to run smoke test for ' + test.data.serviceName, 
function () {
-        mainServiceItemController.runSmokeTestPrimary(test.data.query);
-        expect($.ajax.calledOnce).to.equal(true);
+        beforeEach(function () {
+          mainServiceItemController.set("runSmokeTestErrorCallBack", Em.K);
+          mainServiceItemController.set("runSmokeTestSuccessCallBack", Em.K);
+          mainServiceItemController.runSmokeTestPrimary(test.data.query);
+          this.data = JSON.parse($.ajax.args[0][0].data);
+        });
+
+        it('ajax request is sent', function () {
+          expect($.ajax.calledOnce).to.equal(true);
+        });
+
+        it('RequestInfo.context is valid', function () {
+          
expect(this.data.RequestInfo.context).to.equal(test.RequestInfo.context);
+        });
+
+        it('RequestInfo.command is valid', function () {
+          
expect(this.data.RequestInfo.command).to.equal(test.RequestInfo.command);
+        });
+
+        it('Requests/resource_filter.0.serviceName is valid', function () {
+          
expect(this.data["Requests/resource_filters"][0].serviceName).to.equal(test["Requests/resource_filters"][0].serviceName);
+        });
+
+        it('RequestInfo.operation_level is valid', function () {
+          
expect(this.data.RequestInfo.operation_level).to.be.deep.equal(test.RequestInfo.operation_level);
+        });
 
-        
expect(JSON.parse($.ajax.args[0][0].data).RequestInfo.context).to.equal(test.RequestInfo.context);
-        
expect(JSON.parse($.ajax.args[0][0].data).RequestInfo.command).to.equal(test.RequestInfo.command);
-        
expect(JSON.parse($.ajax.args[0][0].data)["Requests/resource_filters"][0].serviceName).to.equal(test["Requests/resource_filters"][0].serviceName);
-        
expect(JSON.parse($.ajax.args[0][0].data).RequestInfo.operation_level).to.be.deep.equal(test.RequestInfo.operation_level);
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
 
b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
index 15d22fd..699f0a2 100644
--- 
a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
+++ 
b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
@@ -213,6 +213,7 @@ describe('App.ManageConfigGroupsController', function() {
       });
 
       describe("#onPrimaryWizard()", function () {
+
         var ctrl = Em.Object.create({
           selectedService: Em.Object.create({
             selected: false
@@ -220,6 +221,7 @@ describe('App.ManageConfigGroupsController', function() {
           selectedServiceObserver: Em.K,
           setGroupsToDelete: Em.K
         });
+
         beforeEach(function () {
           sinon.spy(ctrl, 'selectedServiceObserver');
           sinon.spy(ctrl, 'setGroupsToDelete');
@@ -227,6 +229,7 @@ describe('App.ManageConfigGroupsController', function() {
           sinon.stub(popup, 'updateConfigGroupOnServicePage', Em.K);
           sinon.stub(popup, 'hide', Em.K);
         });
+
         afterEach(function () {
           ctrl.setGroupsToDelete.restore();
           ctrl.selectedServiceObserver.restore();
@@ -234,44 +237,110 @@ describe('App.ManageConfigGroupsController', function() {
           popup.updateConfigGroupOnServicePage.restore();
           popup.hide.restore();
         });
-        it("groups deleted on 7th step", function () {
-          ctrl.set('name', 'wizardStep7Controller');
-          popup.onPrimaryWizard(ctrl, {toDelete: [1]});
-          expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
-          expect(ctrl.setGroupsToDelete.calledWith([1])).to.be.true;
-          
expect(manageConfigGroupsController.persistConfigGroups.calledOnce).to.be.true;
-          expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
-          expect(popup.hide.calledOnce).to.be.true;
+
+        describe("groups deleted on 7th step", function () {
+
+          beforeEach(function () {
+            ctrl.set('name', 'wizardStep7Controller');
+            popup.onPrimaryWizard(ctrl, {toDelete: [1]});
+          });
+
+          it('selectedServiceObserver is called once', function () {
+            expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
+          });
+          it('setGroupsToDelete is called with [1]', function () {
+            expect(ctrl.setGroupsToDelete.calledWith([1])).to.be.true;
+          });
+          it('persistConfigGroups is called once', function () {
+            
expect(manageConfigGroupsController.persistConfigGroups.calledOnce).to.be.true;
+          });
+          it('updateConfigGroupOnServicePage is called once', function () {
+            expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
+          });
+          it('hide is called once', function () {
+            expect(popup.hide.calledOnce).to.be.true;
+          });
         });
-        it("wizard not on 7th step", function () {
-          ctrl.set('name', '');
-          popup.onPrimaryWizard(ctrl, {});
-          expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
-          expect(ctrl.setGroupsToDelete.called).to.be.false;
-          
expect(manageConfigGroupsController.persistConfigGroups.called).to.be.false;
-          expect(popup.updateConfigGroupOnServicePage.called).to.be.false;
-          expect(popup.hide.calledOnce).to.be.true;
+
+        describe("wizard not on 7th step", function () {
+
+          beforeEach(function () {
+            ctrl.set('name', '');
+            popup.onPrimaryWizard(ctrl, {});
+          });
+
+          it('selectedServiceObserver is called once', function () {
+            expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
+          });
+
+          it('setGroupsToDelete is not called', function () {
+            expect(ctrl.setGroupsToDelete.called).to.be.false;
+          });
+
+          it('persistConfigGroups is not called', function () {
+            
expect(manageConfigGroupsController.persistConfigGroups.called).to.be.false;
+          });
+
+          it('updateConfigGroupOnServicePage is not called', function () {
+            expect(popup.updateConfigGroupOnServicePage.called).to.be.false;
+          });
+
+          it('hide is called once', function () {
+            expect(popup.hide.calledOnce).to.be.true;
+          });
         });
-        it("wizard on 7th step, service selected", function () {
-          ctrl.set('name', 'wizardStep7Controller');
-          ctrl.set('selectedService.selected', true);
-          popup.onPrimaryWizard(ctrl, {toDelete: [1]});
-          expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
-          expect(ctrl.setGroupsToDelete.called).to.be.false;
-          
expect(manageConfigGroupsController.persistConfigGroups.calledOnce).to.be.true;
-          expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
-          expect(popup.hide.calledOnce).to.be.true;
+
+        describe("wizard on 7th step, service selected", function () {
+
+          beforeEach(function () {
+            ctrl.set('name', 'wizardStep7Controller');
+            ctrl.set('selectedService.selected', true);
+            popup.onPrimaryWizard(ctrl, {toDelete: [1]});
+          });
+
+          it('selectedServiceObserver is called once', function () {
+            expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
+          });
+          it('setGroupsToDelete is not called', function () {
+            expect(ctrl.setGroupsToDelete.called).to.be.false;
+          });
+          it('persistConfigGroups is called once', function () {
+            
expect(manageConfigGroupsController.persistConfigGroups.calledOnce).to.be.true;
+          });
+          it('updateConfigGroupOnServicePage is called once', function () {
+            expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
+          });
+          it('hide is called once', function () {
+            expect(popup.hide.calledOnce).to.be.true;
+          });
         });
-        it("wizard on 7th step, no groups to delete", function () {
-          ctrl.set('name', 'wizardStep7Controller');
-          ctrl.set('selectedService.selected', false);
-          popup.onPrimaryWizard(ctrl, {toDelete: []});
-          expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
-          expect(ctrl.setGroupsToDelete.called).to.be.false;
-          
expect(manageConfigGroupsController.persistConfigGroups.calledOnce).to.be.true;
-          expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
-          expect(popup.hide.calledOnce).to.be.true;
+
+        describe("wizard on 7th step, no groups to delete", function () {
+
+          beforeEach(function () {
+            ctrl.set('name', 'wizardStep7Controller');
+            ctrl.set('selectedService.selected', false);
+            popup.onPrimaryWizard(ctrl, {toDelete: []});
+          });
+
+          it('selectedServiceObserver is called once', function () {
+            expect(ctrl.selectedServiceObserver.calledOnce).to.be.true;
+          });
+          it('setGroupsToDelete is not called', function () {
+            expect(ctrl.setGroupsToDelete.called).to.be.false;
+          });
+          it('persistConfigGroups is called once', function () {
+            
expect(manageConfigGroupsController.persistConfigGroups.calledOnce).to.be.true;
+          });
+          it('updateConfigGroupOnServicePage is called once', function () {
+            expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
+          });
+          it('hide is called once', function () {
+            expect(popup.hide.calledOnce).to.be.true;
+          });
+
         });
+
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a487e501/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js 
b/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js
index ff52a35..dee3251 100644
--- a/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js
@@ -35,10 +35,12 @@ describe('App.ReassignMasterWizardStep1Controller', 
function () {
   describe('#loadConfigTags', function() {
     beforeEach(function() {
       sinon.stub(App.ajax, 'send', Em.K);
+      this.stub = sinon.stub(App.router, 'get');
     });
 
     afterEach(function() {
       App.ajax.send.restore();
+      this.stub.restore();
     });
 
     it('tests loadConfigTags', function() {
@@ -48,47 +50,31 @@ describe('App.ReassignMasterWizardStep1Controller', 
function () {
     });
 
     it('tests saveDatabaseType with type', function() {
-      sinon.stub(App.router, 'get', function() {
-        return { saveDatabaseType: Em.K};
-      });
+      this.stub.returns({ saveDatabaseType: Em.K});
 
       controller.saveDatabaseType(true);
       expect(App.router.get.calledOnce).to.be.true;
-
-      App.router.get.restore();
     });
 
     it('tests saveDatabaseType without type', function() {
-      sinon.stub(App.router, 'get', function() {
-        return { saveDatabaseType: Em.K};
-      });
+      this.stub.returns({ saveDatabaseType: Em.K});
 
       controller.saveDatabaseType(false);
       expect(App.router.get.called).to.be.false;
-
-      App.router.get.restore();
     });
 
-    it('tests saveServiceProperties with propertie', function() {
-      sinon.stub(App.router, 'get', function() {
-        return { saveServiceProperties: Em.K};
-      });
+    it('tests saveServiceProperties with properties', function() {
+      this.stub.returns({ saveServiceProperties: Em.K});
 
       controller.saveServiceProperties(true);
       expect(App.router.get.calledOnce).to.be.true;
-
-      App.router.get.restore();
     });
 
     it('tests saveServiceProperties without properties', function() {
-      sinon.stub(App.router, 'get', function() {
-        return { saveServiceProperties: Em.K};
-      });
+      this.stub.returns({ saveServiceProperties: Em.K});
 
       controller.saveServiceProperties(false);
       expect(App.router.get.called).to.be.false;
-
-      App.router.get.restore();
     });
 
     it('tests getDatabaseHost', function() {

Reply via email to