You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/12/23 19:06:51 UTC

[2/3] ambari git commit: AMBARI-14488. Improve Ambari UI UT (p.1) (onechiporenko)

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/controls_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js
index 2699320..cb7a475 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -264,6 +264,7 @@ describe('App.ServiceConfigRadioButtons', function () {
           title: 'Ranger, HDP 2.3, external database'
         }
       ];
+    var rangerVersion = '';
 
     before(function () {
       sinon.stub(Em.run, 'next', function (arg) {
@@ -271,6 +272,18 @@ describe('App.ServiceConfigRadioButtons', function () {
       });
     });
 
+    beforeEach(function () {
+      sinon.stub(view, 'sendRequestRorDependentConfigs', Em.K);
+      this.stub = sinon.stub(App, 'get');
+      this.stub.withArgs('currentStackName').returns('HDP');
+      sinon.stub(App.StackService, 'find', function() {
+        return [Em.Object.create({
+          serviceName: 'RANGER',
+          serviceVersion: rangerVersion || ''
+        })];
+      });
+    });
+
     afterEach(function () {
       App.get.restore();
       App.StackService.find.restore();
@@ -283,26 +296,24 @@ describe('App.ServiceConfigRadioButtons', function () {
 
     cases.forEach(function (item) {
       it(item.title, function () {
-        sinon.stub(App, 'get').withArgs('currentStackName').returns('HDP').withArgs('currentStackVersion').returns(item.currentStackVersion);
-        sinon.stub(App.StackService, 'find', function() {
-          return [Em.Object.create({
-            serviceName: 'RANGER',
-            serviceVersion: item.rangerVersion || ''
-          })];
-        });
+        this.stub.withArgs('currentStackVersion').returns(item.currentStackVersion);
+        rangerVersion = item.rangerVersion;
         view.reopen({controller: item.controller});
-        sinon.stub(view, 'sendRequestRorDependentConfigs', Em.K);
         view.setProperties({
           categoryConfigsAll: item.controller.get('selectedService.configs'),
           serviceConfig: item.serviceConfig
         });
+
         var additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView'),
           additionalView2 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo2).get('additionalView');
+
         expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null);
         expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null);
+
         if (!item.isAdditionalView2Null) {
           expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.driver));
         }
+
       });
     });
 
@@ -654,15 +665,35 @@ describe('App.CheckDBConnectionView', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        view.set('logsPopup', item.logsPopupBefore);
-        view.setResponseStatus(item.isSuccess);
-        expect(view.get('isRequestResolved')).to.be.true;
-        expect(view.setConnectingStatus.calledOnce).to.be.true;
-        expect(view.setConnectingStatus.calledWith(false)).to.be.true;
-        expect(view.get('responseCaption')).to.equal(item.responseCaption);
-        expect(view.get('isConnectionSuccess')).to.equal(item.isConnectionSuccess);
-        expect(view.get('logsPopup')).to.eql(item.logsPopup);
+
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          view.set('logsPopup', item.logsPopupBefore);
+          view.setResponseStatus(item.isSuccess);
+        });
+
+        it('isRequestResolved is true', function () {
+          expect(view.get('isRequestResolved')).to.be.true;
+        });
+
+        it('setConnectingStatus is called with valid arguments', function () {
+          expect(view.setConnectingStatus.calledOnce).to.be.true;
+          expect(view.setConnectingStatus.calledWith(false)).to.be.true;
+        });
+
+        it('responseCaption is valid', function () {
+          expect(view.get('responseCaption')).to.equal(item.responseCaption);
+        });
+
+        it('isConnectionSuccess is valid', function () {
+          expect(view.get('isConnectionSuccess')).to.equal(item.isConnectionSuccess);
+        });
+
+        it('logsPopup is valid', function () {
+          expect(view.get('logsPopup')).to.eql(item.logsPopup);
+        });
+
       });
     });
 
@@ -670,36 +701,7 @@ describe('App.CheckDBConnectionView', function () {
 
   describe('#showLogsPopup', function () {
 
-    var view,
-      cases = [
-        {
-          isConnectionSuccess: true,
-          showAlertPopupCallCount: 0,
-          title: 'successful connection'
-        },
-        {
-          isConnectionSuccess: false,
-          isRequestResolved: true,
-          showAlertPopupCallCount: 1,
-          responseFromServer: 'fail',
-          header: Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL', Em.I18n.t('common.error')),
-          popupMethodExecuted: 'onClose',
-          title: 'failed connection without output data, popup dismissed with Close button'
-        },
-        {
-          isConnectionSuccess: false,
-          isRequestResolved: false,
-          showAlertPopupCallCount: 1,
-          responseFromServer: {
-            stderr: 'stderr',
-            stdout: 'stdout',
-            structuredOut: 'structuredOut'
-          },
-          header: Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL', Em.I18n.t('common.testing')),
-          popupMethodExecuted: 'onPrimary',
-          title: 'check in progress with output data, popup dismissed with OK button'
-        }
-      ];
+    var view;
 
     beforeEach(function () {
       view = App.CheckDBConnectionView.create({
@@ -712,25 +714,61 @@ describe('App.CheckDBConnectionView', function () {
       App.showAlertPopup.restore();
     });
 
-    cases.forEach(function (item) {
-      it(item.title, function () {
-        view.setProperties({
-          isConnectionSuccess: item.isConnectionSuccess,
-          isRequestResolved: item.isRequestResolved,
-          responseFromServer: item.responseFromServer
-        });
+    it('successful connection', function () {
+      view.set('isConnectionSuccess', true);
+      view.showLogsPopup();
+      expect(App.showAlertPopup.callCount).to.equal(0);
+    });
+
+    describe('failed connection without output data, popup dismissed with Close button', function () {
+
+      beforeEach(function () {
+        view.set('isConnectionSuccess', false);
+        view.set('isRequestResolved', true);
+        view.set('responseFromServer', 'fail');
         view.showLogsPopup();
-        expect(App.showAlertPopup.callCount).to.equal(item.showAlertPopupCallCount);
-        if (!item.isConnectionSuccess) {
-          expect(view.get('logsPopup.header')).to.equal(item.header);
-          if (typeof item.responseFromServer == 'object') {
-            expect(view.get('logsPopup.bodyClass').create().get('openedTask')).to.eql(item.responseFromServer);
-          } else {
-            expect(view.get('logsPopup.body')).to.equal(item.responseFromServer);
-          }
-          view.get('logsPopup')[item.popupMethodExecuted]();
-          expect(view.get('logsPopup')).to.be.null;
-        }
+      });
+
+      it('showAlertPopup is called once', function () {
+        expect(App.showAlertPopup.callCount).to.equal(1);
+      });
+      it('logsPopup.header is valid', function () {
+        expect(view.get('logsPopup.header')).to.equal(Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL', Em.I18n.t('common.error')));
+      });
+      it('logsPopup.body is valid', function () {
+        expect(view.get('logsPopup.body')).to.equal('fail');
+      });
+      it('logsPopup is null after close', function () {
+        view.get('logsPopup').onClose();
+        expect(view.get('logsPopup')).to.be.null;
+      });
+    });
+
+    describe('check in progress with output data, popup dismissed with OK button', function () {
+      var response = {
+        stderr: 'stderr',
+        stdout: 'stdout',
+        structuredOut: 'structuredOut'
+      };
+      beforeEach(function () {
+        view.set('isConnectionSuccess', false);
+        view.set('isRequestResolved', false);
+        view.set('responseFromServer', response);
+        view.showLogsPopup();
+      });
+
+      it('showAlertPopup is called once', function () {
+        expect(App.showAlertPopup.callCount).to.equal(1);
+      });
+      it('logsPopup.header is valid', function () {
+        expect(view.get('logsPopup.header')).to.equal(Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL', Em.I18n.t('common.testing')));
+      });
+      it('logsPopup.bodyClass is valid', function () {
+        expect(view.get('logsPopup.bodyClass').create().get('openedTask')).to.eql(response);
+      });
+      it('logsPopup is null after primary click', function () {
+        view.get('logsPopup').onPrimary();
+        expect(view.get('logsPopup')).to.be.null;
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/custom_date_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/custom_date_popup_test.js b/ambari-web/test/views/common/custom_date_popup_test.js
index 1a5ae13..a94629f 100644
--- a/ambari-web/test/views/common/custom_date_popup_test.js
+++ b/ambari-web/test/views/common/custom_date_popup_test.js
@@ -33,29 +33,60 @@ describe('CustomDatePopup', function() {
       expect(context.cancel.calledOnce).to.ok;
     });
 
-    it('empty values passed for end and start dates, validation should fail with appropriate message', function() {
-      expect(popup.onPrimary()).to.false;
-      expect(customDatePopup.get('errors.isStartDateError')).to.ok;
-      expect(customDatePopup.get('errors.isEndDateError')).to.ok;
-      expect(customDatePopup.get('errorMessages.startDate')).to.equal(Em.I18n.t('jobs.customDateFilter.error.required'));
-      expect(customDatePopup.get('errorMessages.endDate')).to.equal(Em.I18n.t('jobs.customDateFilter.error.required'));
+    describe('empty values passed for end and start dates, validation should fail with appropriate message', function () {
+      it('onPrimary is false', function () {
+        expect(popup.onPrimary()).to.false;
+      });
+      it('isStartDateError is true', function () {
+        expect(customDatePopup.get('errors.isStartDateError')).to.ok;
+      });
+      it('isEndDateError is true', function () {
+        expect(customDatePopup.get('errors.isEndDateError')).to.ok;
+      });
+      it('startDate invalid', function () {
+        expect(customDatePopup.get('errorMessages.startDate')).to.equal(Em.I18n.t('jobs.customDateFilter.error.required'));
+      });
+      it('endDate invalid', function () {
+        expect(customDatePopup.get('errorMessages.endDate')).to.equal(Em.I18n.t('jobs.customDateFilter.error.required'));
+      });
     });
 
-    it('passed start date is greater then end data, validation should fail with apporpriate message', function() {
-      customDatePopup.set('customDateFormFields.startDate', '11/11/11');
-      customDatePopup.set('customDateFormFields.endDate', '11/10/11');
-      expect(popup.onPrimary()).to.false;
-      expect(customDatePopup.get('errors.isStartDateError')).to.false;
-      expect(customDatePopup.get('errors.isEndDateError')).to.ok;
-      expect(customDatePopup.get('errorMessages.endDate')).to.equal(Em.I18n.t('jobs.customDateFilter.error.date.order'));
+    describe('passed start date is greater then end data, validation should fail with apporpriate message', function () {
+      beforeEach(function () {
+        customDatePopup.set('customDateFormFields.startDate', '11/11/11');
+        customDatePopup.set('customDateFormFields.endDate', '11/10/11');
+      });
+
+      it('onPrimary is false', function () {
+        expect(popup.onPrimary()).to.false;
+      });
+      it('isStartDateError is false', function () {
+        expect(customDatePopup.get('errors.isStartDateError')).to.false;
+      });
+      it('isEndDateError is true', function () {
+        expect(customDatePopup.get('errors.isEndDateError')).to.ok;
+      });
+      it('endDate invalid', function () {
+        expect(customDatePopup.get('errorMessages.endDate')).to.equal(Em.I18n.t('jobs.customDateFilter.error.date.order'));
+      });
     });
 
-    it('valid values passed, `valueObject` should contain `endTime` and `startTime`', function() {
-      customDatePopup.set('customDateFormFields.startDate', '11/11/11');
-      customDatePopup.set('customDateFormFields.endDate', '11/12/11');
-      popup.onPrimary();
-      expect(context.get('actualValues.startTime')).to.equal(new Date('11/11/11 01:00 AM').getTime());
-      expect(context.get('actualValues.endTime')).to.equal(new Date('11/12/11 01:00 AM').getTime());
+    describe('valid values passed, `valueObject` should contain `endTime` and `startTime`', function () {
+
+      beforeEach(function () {
+        customDatePopup.set('customDateFormFields.startDate', '11/11/11');
+        customDatePopup.set('customDateFormFields.endDate', '11/12/11');
+        popup.onPrimary();
+      });
+
+      it('startTime is valid', function() {
+        expect(context.get('actualValues.startTime')).to.equal(new Date('11/11/11 01:00 AM').getTime());
+      });
+      it('endTime is valid', function() {
+        expect(context.get('actualValues.endTime')).to.equal(new Date('11/12/11 01:00 AM').getTime());
+      });
+
     });
+
   });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/filter_combo_cleanable_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/filter_combo_cleanable_test.js b/ambari-web/test/views/common/filter_combo_cleanable_test.js
index 5cb5003..0c36c33 100644
--- a/ambari-web/test/views/common/filter_combo_cleanable_test.js
+++ b/ambari-web/test/views/common/filter_combo_cleanable_test.js
@@ -26,14 +26,20 @@ describe('App.FilterComboCleanableView', function() {
 
   describe('#didInsertElement', function() {
 
-    it('should clean filter when created', function() {
+    beforeEach(function () {
       sinon.stub(App, 'popover', Em.K);
+    });
+
+    afterEach(function () {
+      App.popover.restore();
+    });
+
+    it('should clean filter when created', function() {
       view.setProperties({
         filter: 'some value',
         popoverDescription: ['', '']
       });
       view.didInsertElement();
-      App.popover.restore();
       expect(view.get('filter')).to.be.empty;
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
index 6addbed..5004ef9 100644
--- a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
+++ b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
@@ -43,6 +43,21 @@ describe('#App.ManageCredentialsFormView', function() {
   App.TestAliases.testAsComputedIfThenElse(getView(), 'hintMessage', 'storePersisted', Em.I18n.t('admin.kerberos.credentials.store.hint.supported'), Em.I18n.t('admin.kerberos.credentials.store.hint.not.supported'));
 
   describe('#prepareContent', function() {
+
+    var credentials;
+
+    beforeEach(function () {
+      this.stub = sinon.stub(App, 'get');
+      sinon.stub(credentialUtils, 'credentials', function(clusterName, callback) {
+        callback(credentials);
+      });
+    });
+
+    afterEach(function () {
+      App.get.restore();
+      credentialUtils.credentials.restore();
+    });
+
     [
       {
         isStorePersistent: true,
@@ -76,17 +91,13 @@ describe('#App.ManageCredentialsFormView', function() {
       }
     ].forEach(function(test) {
       it(test.m, function(done) {
-        sinon.stub(credentialUtils, 'credentials', function(clusterName, callback) {
-          callback(test.credentials);
-        });
-        sinon.stub(App, 'get').withArgs('isCredentialStorePersistent').returns(test.e.storePersisted);
+        credentials = test.credentials;
+        this.stub.withArgs('isCredentialStorePersistent').returns(test.e.storePersisted);
         view.prepareContent();
         Em.run.next(function() {
           assert.equal(view.get('isRemovable'), test.e.isRemovable, '#isRemovable property validation');
           assert.equal(view.get('isRemoveDisabled'), test.e.isRemoveDisabled, '#isRemoveDisabled property validation');
           assert.equal(view.get('storePersisted'), test.e.storePersisted, '#storePersisted property validation');
-          credentialUtils.credentials.restore();
-          App.get.restore();
           done();
         });
       });
@@ -113,39 +124,55 @@ describe('#App.ManageCredentialsFormView', function() {
   });
 
   describe('fields validation', function() {
+    var t = Em.I18n.t;
+
     it('should flow validation', function() {
-      var t = Em.I18n.t;
       assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled on initial state');
+    });
+
+    it('principal is not empty', function() {
       view.set('principal', ' a');
-      assert.equal(view.get('principalError'), t('host.spacesValidation'), 'principal contains spaces, appropriate message shown');
+      expect(view.get('principalError')).to.equal(t('host.spacesValidation'));
       assert.isTrue(view.get('isPrincipalDirty'), 'principal name modified');
       assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled because principal not valid');
+    });
+
+    it('principal is empty', function() {
+      view.set('principal', ' a');
       view.set('principal', '');
-      assert.equal(view.get('principalError'), t('admin.users.editError.requiredField'), 'principal is empty, appropriate message shown');
+      expect(view.get('principalError')).to.equal(t('admin.users.editError.requiredField'));
+    });
+
+    it('principal is not empty (2)', function() {
       view.set('principal', 'some_name');
       assert.isFalse(view.get('principalError'), 'principal name valid no message shown');
       assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled because password field not modified');
+    });
+
+    it('password is updated', function() {
       view.set('password', '1');
       view.set('password', '');
-      assert.equal(view.get('passwordError'), t('admin.users.editError.requiredField'), 'password is empty, appropriate message shown');
+      expect(view.get('passwordError')).to.equal(t('admin.users.editError.requiredField'));
       assert.isTrue(view.get('isPasswordDirty'), 'password modified');
       assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled because password field is empty');
+    });
+
+    it('password is updated (2)', function() {
       view.set('password', 'some_pass');
+      view.set('principal', 'some_name');
       assert.isFalse(view.get('passwordError'), 'password valid no message shown');
       assert.isFalse(view.get('isSubmitDisabled'), 'submit enabled all fields are valid');
     });
+
   });
 
   describe('#removeKDCCredentials', function() {
-    it('should show confirmation popup', function() {
-      var popup = view.removeKDCCredentials().popup;
-      expect(popup).be.instanceof(App.ModalPopup);
-      popup.destroy();
-    });
-    it('should call credentialUtils#removeCredentials', function() {
+
+    var popup;
+
+    beforeEach(function () {
+      popup = view.removeKDCCredentials().popup;
       this.clock = sinon.useFakeTimers();
-      var popup = view.removeKDCCredentials().popup;
-      assert.isFalse(view.get('actionStatus'), '#actionStatus before remove');
       sinon.stub(credentialUtils, 'removeCredentials', function() {
         var dfd = $.Deferred();
         setTimeout(function() {
@@ -153,17 +180,35 @@ describe('#App.ManageCredentialsFormView', function() {
         }, 500);
         return dfd.promise();
       });
+    });
+
+    afterEach(function () {
+      popup.destroy();
+      credentialUtils.removeCredentials.restore();
+      this.clock.restore();
+    });
+
+    it('should show confirmation popup', function() {
+      expect(popup).be.instanceof(App.ModalPopup);
+    });
+
+    it('on popup open', function() {
+      assert.isFalse(view.get('actionStatus'), '#actionStatus before remove');
+    });
+
+    it('on Primary', function() {
       popup.onPrimary();
       assert.isTrue(view.get('isActionInProgress'), 'action in progress');
       assert.isTrue(view.get('isRemoveDisabled'), 'remove button disabled');
       assert.isTrue(view.get('isSubmitDisabled'), 'submit button disabled');
+    });
+
+    it('after 1s', function() {
+      popup.onPrimary();
       this.clock.tick(1000);
       assert.isFalse(view.get('isActionInProgress'), 'action finished');
       assert.equal(Em.I18n.t('common.success'), view.get('actionStatus'), '#actionStatus after remove');
       assert.isTrue(view.get('parentView.isCredentialsRemoved'), 'parentView#isCredentialsRemoved property should be triggered when remove complete');
-      credentialUtils.removeCredentials.restore();
-      this.clock.restore();
-      popup.destroy();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/modal_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popup_test.js b/ambari-web/test/views/common/modal_popup_test.js
index 6605612..ed58834 100644
--- a/ambari-web/test/views/common/modal_popup_test.js
+++ b/ambari-web/test/views/common/modal_popup_test.js
@@ -39,10 +39,17 @@ describe('App.ModalPopup', function() {
 
   describe('#didInsertElement', function () {
 
+    beforeEach(function () {
+      this.spy = sinon.spy(popup, "focusElement");
+    });
+
+    afterEach(function () {
+      this.spy.restore();
+    });
+
     it('should focus on the first input element', function () {
-      var spy = sinon.spy(popup, "focusElement");
       popup.didInsertElement();
-      expect(spy.called).to.be.true;
+      expect(this.spy.called).to.be.true;
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
index 7f02730..232c267 100644
--- a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
+++ b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
@@ -245,26 +245,49 @@ describe('App.showClusterCheckPopup', function () {
   });
 
   cases.forEach(function (item) {
-    it(item.title, function () {
-      var popup = App.showClusterCheckPopup(item.inputData.data, item.inputData.popup, item.inputData.configs, item.inputData.upgradeVersion),
+
+    describe(item.title, function () {
+
+      var popup;
+      var popupBody;
+
+      beforeEach(function () {
+        popup = App.showClusterCheckPopup(item.inputData.data, item.inputData.popup, item.inputData.configs, item.inputData.upgradeVersion);
         popupBody = popup.bodyClass.create();
-      popup.onPrimary();
-      Em.keys(item.result).forEach(function (key) {
-        expect(popup[key]).to.equal(item.result[key]);
+        popup.onPrimary();
       });
-      Em.keys(item.bodyResult).forEach(function (key) {
-        expect(popupBody[key]).to.eql(item.bodyResult[key]);
+
+      it('result', function () {
+        Em.keys(item.result).forEach(function (key) {
+          expect(popup[key]).to.equal(item.result[key]);
+        });
+      });
+
+      it('bodyResult', function () {
+        Em.keys(item.bodyResult).forEach(function (key) {
+          expect(popupBody[key]).to.eql(item.bodyResult[key]);
+        });
       });
-      expect(isCallbackExecuted).to.equal(item.isCallbackExecuted);
+
+      it('callbackExecuted', function () {
+        expect(isCallbackExecuted).to.equal(item.isCallbackExecuted);
+      });
+
       if (item.bodyResult.hasConfigsMergeConflicts) {
-        var configsMergeTable = popupBody.configsMergeTable.create();
-        configsMergeTable.didInsertElement();
-        expect(configsMergeTable.configs).to.eql(item.configsResult);
-        expect(App.tooltip.calledOnce).to.be.true;
-        expect(App.tooltip.firstCall.args[1].title).to.equal(item.inputData.upgradeVersion);
-      } else {
-        expect(App.tooltip.calledOnce).to.be.false;
+        it('hasConfigsMergeConflicts = true', function () {
+          var configsMergeTable = popupBody.configsMergeTable.create();
+          configsMergeTable.didInsertElement();
+          expect(configsMergeTable.configs).to.eql(item.configsResult);
+          expect(App.tooltip.calledOnce).to.be.true;
+          expect(App.tooltip.firstCall.args[1].title).to.equal(item.inputData.upgradeVersion);
+        });
       }
+      else {
+        it('App.tooltip is not called', function () {
+          expect(App.tooltip.called).to.be.false;
+        });
+      }
+
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js b/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
index f80f016..3fc466f 100644
--- a/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
+++ b/ambari-web/test/views/common/modal_popups/hosts_table_list_popup_test.js
@@ -49,14 +49,32 @@ describe('App.showHostsTableListPopup', function () {
   ];
 
   cases.forEach(function (item) {
-    it(item.title, function () {
-      var popup = App.showHostsTableListPopup(item.header, item.hostName, item.items),
+
+    describe(item.title, function () {
+
+      var popup;
+      var popupBody;
+
+      beforeEach(function () {
+        popup = App.showHostsTableListPopup(item.header, item.hostName, item.items);
         popupBody = popup.bodyClass.create();
-      expect(popup.header).to.equal(item.header);
-      expect(popupBody.get('hostName')).to.equal(item.hostName);
-      expect(popupBody.get('items')).to.eql(item.items);
-      expect(popupBody.get('isObjectsList')).to.equal(item.isObjectsList);
+      });
+
+      it('header is valid', function () {
+        expect(popup.header).to.equal(item.header);
+      });
+      it('hostName is valid', function () {
+        expect(popupBody.get('hostName')).to.equal(item.hostName);
+      });
+      it('items are valid', function () {
+        expect(popupBody.get('items')).to.eql(item.items);
+      });
+      it('isObjectsList is valid', function () {
+        expect(popupBody.get('isObjectsList')).to.equal(item.isObjectsList);
+      });
+
     });
+
   });
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/common/widget/graph_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/widget/graph_widget_view_test.js b/ambari-web/test/views/common/widget/graph_widget_view_test.js
index 3bb5028..e34c081 100644
--- a/ambari-web/test/views/common/widget/graph_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/graph_widget_view_test.js
@@ -194,33 +194,48 @@ describe('App.GraphWidgetView', function () {
       }
     ];
 
-    beforeEach(function () {
-      sinon.stub(view, 'prepareCSV').returns('key,value');
-      sinon.stub(fileUtils, 'downloadTextFile', Em.K);
-      sinon.stub(App, 'showAlertPopup', Em.K);
-    });
+    cases.forEach(function (item) {
 
-    afterEach(function () {
-      view.prepareCSV.restore();
-      fileUtils.downloadTextFile.restore();
-      App.showAlertPopup.restore();
-    });
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(view, 'prepareCSV').returns('key,value');
+          sinon.stub(fileUtils, 'downloadTextFile', Em.K);
+          sinon.stub(App, 'showAlertPopup', Em.K);
+          view.set('data', item.data);
+          view.exportGraphData(item.event || {});
+        });
+
+        afterEach(function () {
+          view.prepareCSV.restore();
+          fileUtils.downloadTextFile.restore();
+          App.showAlertPopup.restore();
+        });
+
+        it('isExportMenuHidden is true', function () {
+          expect(view.get('isExportMenuHidden')).to.be.true;
+        });
+
+        it('downloadTextFile calls count is calid', function () {
+          expect(fileUtils.downloadTextFile.callCount).to.equal(item.downloadTextFileCallCount);
+        });
+
+        it('showAlertPopup calls count is valid', function () {
+          expect(App.showAlertPopup.callCount).to.equal(item.showAlertPopupCallCount);
+        });
 
-    cases.forEach(function (item) {
-      it(item.title, function () {
-        view.set('data', item.data);
-        view.exportGraphData(item.event || {});
-        expect(view.get('isExportMenuHidden')).to.be.true;
-        expect(fileUtils.downloadTextFile.callCount).to.equal(item.downloadTextFileCallCount);
-        expect(App.showAlertPopup.callCount).to.equal(item.showAlertPopupCallCount);
         if (item.downloadTextFileCallCount) {
-          var fileType = item.event && item.event.context ? 'csv' : 'json',
-            downloadArgs = fileUtils.downloadTextFile.firstCall.args;
-          expect(downloadArgs[0].replace(/\s/g, '')).to.equal(item.fileData);
-          expect(downloadArgs[1]).to.equal(fileType);
-          expect(downloadArgs[2]).to.equal('data.' + fileType);
+          it('download args are valid', function () {
+            var fileType = item.event && item.event.context ? 'csv' : 'json',
+              downloadArgs = fileUtils.downloadTextFile.firstCall.args;
+            expect(downloadArgs[0].replace(/\s/g, '')).to.equal(item.fileData);
+            expect(downloadArgs[1]).to.equal(fileType);
+            expect(downloadArgs[2]).to.equal('data.' + fileType);
+          });
         }
+
       });
+
     });
 
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/admin/stack_upgrade/menu_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/menu_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/menu_view_test.js
index cc06a5f..f118e76 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/menu_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/menu_view_test.js
@@ -27,6 +27,10 @@ describe('App.MainAdminStackMenuView', function () {
 
   describe('#content', function () {
 
+    beforeEach(function () {
+      this.stub = sinon.stub(App, 'get');
+    });
+
     afterEach(function () {
       App.get.restore();
     });
@@ -44,8 +48,7 @@ describe('App.MainAdminStackMenuView', function () {
         }
       ]).forEach(function (test) {
         it(test.m, function () {
-          var stub = sinon.stub(App, 'get');
-          stub.withArgs('stackVersionsAvailable').returns(test.stackVersionsAvailable);
+          this.stub.withArgs('stackVersionsAvailable').returns(test.stackVersionsAvailable);
           view.propertyDidChange('content');
           expect(view.get('content').findProperty('name', 'versions').get('hidden')).to.equal(test.e);
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index 4561449..b151ee4 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -203,16 +203,22 @@ describe('App.mainAdminStackVersionsView', function () {
         }
       ];
 
+    var displayOlderVersions = false;
+
+    beforeEach(function () {
+      sinon.stub(App, 'get', function (key) {
+        return key == 'supports.displayOlderVersions' ? displayOlderVersions : Em.get(App, key);
+      });
+    });
+
     afterEach(function () {
       App.get.restore();
     });
 
     testCases.forEach(function(t) {
-      var msg = t.filter.get('value') ? t.filter.get('value') : "All";
+      var msg = t.filter.get('value') || "All";
       it(t.message || "filter By " + msg, function () {
-        sinon.stub(App, 'get', function (key) {
-          return key == 'supports.displayOlderVersions' ? Boolean(t.displayOlderVersions) : Em.get(App, key);
-        });
+        displayOlderVersions = t.displayOlderVersions;
         view.set('controller.currentVersion', t.noCurrentVersion ? null : {repository_version: '2.2.1.1'});
         expect(view.filterBy(versions, t.filter)).to.eql(t.filteredVersions);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/admin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin_test.js b/ambari-web/test/views/main/admin_test.js
index 55551b7..3e6b4f6 100644
--- a/ambari-web/test/views/main/admin_test.js
+++ b/ambari-web/test/views/main/admin_test.js
@@ -72,13 +72,17 @@ describe('App.MainAdminView', function () {
       }
     ];
 
+    beforeEach(function () {
+      this.stub = sinon.stub(App, 'get');
+    });
+
     afterEach(function () {
       App.get.restore();
     });
 
     cases.forEach(function (item) {
       it(item.title, function () {
-        sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
+        this.stub.withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
         view.propertyDidChange('categories');
         expect(view.get('categories')).to.eql(item.categories);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/charts/heatmap/heatmap_host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/charts/heatmap/heatmap_host_test.js b/ambari-web/test/views/main/charts/heatmap/heatmap_host_test.js
index 0ce182a..e7fe267 100644
--- a/ambari-web/test/views/main/charts/heatmap/heatmap_host_test.js
+++ b/ambari-web/test/views/main/charts/heatmap/heatmap_host_test.js
@@ -157,91 +157,168 @@ describe('App.MainChartsHeatmapHostView', function () {
       this.mock.restore();
     });
 
-    it("set diskUsage", function () {
-      var childView = Em.Object.create({
-        details: {
-          diskUsage: ''
-        }
+    describe('set diskUsage', function () {
+      var childView;
+      beforeEach(function () {
+        childView = Em.Object.create({
+          details: {
+            diskUsage: ''
+          }
+        });
+        this.mock.returns(childView);
+        view.set('content', {
+          diskTotal: 100,
+          diskFree: 50
+        });
+        view.mouseEnter();
+      });
+
+      it("details.diskUsage = usage", function () {
+        expect(childView.get('details.diskUsage')).to.equal('usage');
+      });
+
+      it("getUsage is called with valid arguments", function () {
+        expect(view.getUsage.calledWith(100, 50)).to.be.true;
       });
-      this.mock.returns(childView);
-      view.set('content', {
-        diskTotal: 100,
-        diskFree: 50
+
+      it("setMetric is called once", function () {
+        expect(view.setMetric.calledOnce).to.be.true;
+      });
+
+      it("openDetailsBlock is called once", function () {
+        expect(view.openDetailsBlock.calledOnce).to.be.true;
       });
-      view.mouseEnter();
-      expect(childView.get('details.diskUsage')).to.equal('usage');
-      expect(view.getUsage.calledWith(100, 50)).to.be.true;
-      expect(view.setMetric.calledOnce).to.be.true;
-      expect(view.openDetailsBlock.calledOnce).to.be.true;
+
     });
 
-    it("set cpuUsage", function () {
-      var childView = Em.Object.create({
-        details: {
-          cpuUsage: ''
-        }
+    describe('set cpuUsage', function () {
+      var childView;
+      beforeEach(function () {
+        childView = Em.Object.create({
+          details: {
+            cpuUsage: ''
+          }
+        });
+        this.mock.returns(childView);
+        view.set('content', {
+          cpuSystem: 100,
+          cpuUser: 50
+        });
+        view.mouseEnter();
       });
-      this.mock.returns(childView);
-      view.set('content', {
-        cpuSystem: 100,
-        cpuUser: 50
+
+      it("details.cpuUsage = cpu_usage", function () {
+        expect(childView.get('details.cpuUsage')).to.equal('cpu_usage');
+      });
+
+      it("getCpuUsage is called with valid arguments", function () {
+        expect(view.getCpuUsage.calledWith(100, 50)).to.be.true;
+      });
+
+      it("setMetric is called once", function () {
+        expect(view.setMetric.calledOnce).to.be.true;
+      });
+
+      it("openDetailsBlock is called once", function () {
+        expect(view.openDetailsBlock.calledOnce).to.be.true;
       });
-      view.mouseEnter();
-      expect(childView.get('details.cpuUsage')).to.equal('cpu_usage');
-      expect(view.getCpuUsage.calledWith(100, 50)).to.be.true;
-      expect(view.setMetric.calledOnce).to.be.true;
-      expect(view.openDetailsBlock.calledOnce).to.be.true;
+
     });
 
-    it("set memoryUsage", function () {
-      var childView = Em.Object.create({
-        details: {
-          memoryUsage: ''
-        }
+    describe('set memoryUsage', function () {
+      var childView;
+      beforeEach(function () {
+        childView = Em.Object.create({
+          details: {
+            memoryUsage: ''
+          }
+        });
+        this.mock.returns(childView);
+        view.set('content', {
+          memTotal: 100,
+          memFree: 50
+        });
+        view.mouseEnter();
+      });
+
+      it("details.memoryUsage = usage", function () {
+        expect(childView.get('details.memoryUsage')).to.equal('usage');
       });
-      this.mock.returns(childView);
-      view.set('content', {
-        memTotal: 100,
-        memFree: 50
+
+      it("getUsage is called with valid arguments", function () {
+        expect(view.getUsage.calledWith(100, 50)).to.be.true;
+      });
+
+      it("setMetric is called once", function () {
+        expect(view.setMetric.calledOnce).to.be.true;
       });
-      view.mouseEnter();
-      expect(childView.get('details.memoryUsage')).to.equal('usage');
-      expect(view.getUsage.calledWith(100, 50)).to.be.true;
-      expect(view.setMetric.calledOnce).to.be.true;
-      expect(view.openDetailsBlock.calledOnce).to.be.true;
+
+      it("openDetailsBlock is called once", function () {
+        expect(view.openDetailsBlock.calledOnce).to.be.true;
+      });
+
     });
 
-    it("set hostComponents", function () {
-      var childView = Em.Object.create({
-        details: {
-          hostComponents: ''
-        }
+    describe('set hostComponents', function () {
+      var childView;
+      beforeEach(function () {
+        childView = Em.Object.create({
+          details: {
+            hostComponents: ''
+          }
+        });
+        this.mock.returns(childView);
+        view.set('content', {
+          hostComponents: ['host1']
+        });
+        view.mouseEnter();
+      });
+
+      it("hostComponents = ['c1']", function () {
+        expect(childView.get('details.hostComponents')).to.eql(['c1']);
+      });
+
+      it("getHostComponents is called with valid arguments", function () {
+        expect(view.getHostComponents.calledWith(['host1'])).to.be.true;
       });
-      this.mock.returns(childView);
-      view.set('content', {
-        hostComponents: ['host1']
+
+      it("setMetric is called once", function () {
+        expect(view.setMetric.calledOnce).to.be.true;
+      });
+
+      it("openDetailsBlock is called once", function () {
+        expect(view.openDetailsBlock.calledOnce).to.be.true;
       });
-      view.mouseEnter();
-      expect(childView.get('details.hostComponents')).to.eql(['c1']);
-      expect(view.getHostComponents.calledWith(['host1'])).to.be.true;
-      expect(view.setMetric.calledOnce).to.be.true;
-      expect(view.openDetailsBlock.calledOnce).to.be.true;
+
     });
 
-    it("set hostName", function () {
-      var childView = Em.Object.create({
-        details: {
-          hostName: ''
-        }
+    describe('set hostName', function () {
+      var childView;
+      beforeEach(function () {
+        childView = Em.Object.create({
+          details: {
+            hostName: ''
+          }
+        });
+        this.mock.returns(childView);
+        view.set('content', {
+          hostName: 'host1'
+        });
+        view.mouseEnter();
       });
-      this.mock.returns(childView);
-      view.set('content', {
-        hostName: 'host1'
+
+      it("hostName = host1", function () {
+        expect(childView.get('details.hostName')).to.equal('host1');
+      });
+
+      it("setMetric is called once", function () {
+        expect(view.setMetric.calledOnce).to.be.true;
       });
-      view.mouseEnter();
-      expect(childView.get('details.hostName')).to.equal('host1');
-      expect(view.setMetric.calledOnce).to.be.true;
-      expect(view.openDetailsBlock.calledOnce).to.be.true;
+
+      it("openDetailsBlock is called once", function () {
+        expect(view.openDetailsBlock.calledOnce).to.be.true;
+      });
+
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index 36a1a42..39b2a48 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -147,25 +147,38 @@ describe('App.DashboardWidgetView', function () {
       thresh1: '1',
       thresh2: '2'
     });
-    before(function () {
+    beforeEach(function () {
       sinon.spy(obj, 'observeThresh1Value');
       sinon.spy(obj, 'observeThresh2Value');
       sinon.stub(dashboardWidgetView.get('parentView'), 'getUserPref').returns({
         complete: Em.K
       });
+      var popup = dashboardWidgetView.showEditDialog(obj);
+      popup.onPrimary();
     });
-    after(function () {
+    afterEach(function () {
       obj.observeThresh1Value.restore();
       obj.observeThresh2Value.restore();
       dashboardWidgetView.get('parentView').getUserPref.restore();
     });
-    it("open popup", function () {
-      var popup = dashboardWidgetView.showEditDialog(obj);
-      popup.onPrimary();
+
+    it("observeThresh1Value is called once", function () {
       expect(obj.observeThresh1Value.calledOnce).to.be.true;
+    });
+
+    it("observeThresh2Value is called once", function () {
       expect(obj.observeThresh2Value.calledOnce).to.be.true;
+    });
+
+    it("thresh1 = 1", function () {
       expect(dashboardWidgetView.get('thresh1')).to.equal(1);
+    });
+
+    it("thresh2 = 2", function () {
       expect(dashboardWidgetView.get('thresh2')).to.equal(2);
+    });
+
+    it("getUserPref is called once", function () {
       expect(dashboardWidgetView.get('parentView').getUserPref.calledOnce).to.be.true;
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js b/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
index e68a8e3..10ddd3b 100644
--- a/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/datanode_live_test.js
@@ -51,18 +51,24 @@ describe('App.DataNodeUpView', function() {
     }
   ];
 
-  tests.forEach(function(test) {
-    describe('', function() {
+  tests.forEach(function(test, index) {
+
+    describe('test#' + (index + 1), function () {
+
       var dataNodeUpView = App.DataNodeUpView.create({model_type:null, data: test.data, content: test.data.toString()});
+
       it('isRed', function() {
         expect(dataNodeUpView.get('isRed')).to.equal(test.e.isRed);
       });
+
       it('isOrange', function() {
         expect(dataNodeUpView.get('isOrange')).to.equal(test.e.isOrange);
       });
+
       it('isGreen', function() {
         expect(dataNodeUpView.get('isGreen')).to.equal(test.e.isGreen);
       });
+
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js b/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
index 075af15..a217495 100644
--- a/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
@@ -27,14 +27,17 @@ describe('App.DataNodeComponentView', function () {
   });
 
   describe("#getDNDecommissionStatus()", function () {
+
     beforeEach(function () {
       this.stub = sinon.stub(App.HDFSService, 'find');
       sinon.stub(App.ajax, 'send');
     });
+
     afterEach(function () {
       App.ajax.send.restore();
       this.stub.restore();
     });
+
     it("snameNode absent and no activeNameNode", function () {
       this.stub.returns([
         Em.Object.create({
@@ -49,6 +52,7 @@ describe('App.DataNodeComponentView', function () {
         "componentName": "NAMENODE"
       });
     });
+
     it("snameNode present and no activeNameNode", function () {
       this.stub.returns([
         Em.Object.create({
@@ -63,6 +67,7 @@ describe('App.DataNodeComponentView', function () {
         "componentName": "NAMENODE"
       });
     });
+
     it("snameNode absent and activeNameNode valid", function () {
       this.stub.returns([
         Em.Object.create({
@@ -77,6 +82,7 @@ describe('App.DataNodeComponentView', function () {
         "componentName": "NAMENODE"
       });
     });
+
   });
 
   describe("#getDNDecommissionStatusSuccessCallback()", function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/host/menu_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/menu_test.js b/ambari-web/test/views/main/host/menu_test.js
index d4e6d6a..4540486 100644
--- a/ambari-web/test/views/main/host/menu_test.js
+++ b/ambari-web/test/views/main/host/menu_test.js
@@ -27,6 +27,10 @@ describe('App.MainHostMenuView', function () {
 
   describe('#content', function () {
 
+    beforeEach(function () {
+      this.mock = sinon.stub(App, 'get');
+    });
+
     afterEach(function () {
       App.get.restore();
     });
@@ -58,9 +62,8 @@ describe('App.MainHostMenuView', function () {
         }
       ]).forEach(function (test) {
         it(test.m, function () {
-          var stub = sinon.stub(App, 'get');
-          stub.withArgs('stackVersionsAvailable').returns(test.stackVersionsAvailable);
-          stub.withArgs('supports.stackUpgrade').returns(test.stackUpgrade);
+          this.mock.withArgs('stackVersionsAvailable').returns(test.stackVersionsAvailable);
+          this.mock.withArgs('supports.stackUpgrade').returns(test.stackUpgrade);
           view.propertyDidChange('content');
           expect(view.get('content').findProperty('name', 'versions').get('hidden')).to.equal(test.e);
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/menu_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/menu_test.js b/ambari-web/test/views/main/menu_test.js
index ca8a613..04d13f7 100644
--- a/ambari-web/test/views/main/menu_test.js
+++ b/ambari-web/test/views/main/menu_test.js
@@ -91,13 +91,17 @@ describe('App.MainMenuView', function () {
         }
       ];
 
+      beforeEach(function () {
+        this.mock = sinon.stub(App, 'get');
+      });
+
       afterEach(function () {
-        App.get.restore();
+        this.mock.restore();
       });
 
       cases.forEach(function (item) {
         it(item.title, function () {
-          sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
+          this.mock.withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
           var menuItem = mainMenuView.get('content').findProperty('content.routing', item.itemName);
           menuItem.propertyDidChange('dropdownCategories');
           expect(menuItem.get('dropdownCategories')).to.eql(item.dropdownCategories);

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js b/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
index a43c345..4ba93ac 100644
--- a/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
+++ b/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
@@ -22,28 +22,49 @@ require('views/main/service/info/metrics/ambari_metrics/regionserver_base');
 
 describe('App.ChartServiceMetricsAMS_RegionServerBaseView', function () {
 
-  var regionServerView = App.ChartServiceMetricsAMS_RegionServerBaseView.extend({
-    id: "service-metrics-ambari-metrics-region-server-test",
-    title: 'test-title',
-    ajaxIndex: 'service.metrics.ambari_metrics.region_server.regions',
-    displayName: 'test-display-name',
-    regionServerName: 'test'
-  }).create();
-
-  it('#transformData should transform data for regionserver requests', function () {
-    var jsonData = {
-      "metrics": {
-        "hbase": {
-          "regionserver": {
-            "test": [[11.0, 1424948261], [11.0, 1424948306], [11.0, 1424948321]]
-          }
+  var regionServerView;
+  var jsonData = {
+    "metrics": {
+      "hbase": {
+        "regionserver": {
+          "test": [[11.0, 1424948261], [11.0, 1424948306], [11.0, 1424948321]]
         }
       }
-    };
-    var result = regionServerView.transformToSeries(jsonData);
-    expect(result[0].name === regionServerView.displayName).to.be.true;
-    expect(result[0].data.length === jsonData.metrics.hbase.regionserver['test'].length).to.be.true;
-    expect(result[0].data[0]).to.have.property('y').to.equal(11);
-    expect(result[0].data[0]).to.have.property('x').to.equal(1424948261);
+    }
+  };
+
+  beforeEach(function () {
+    regionServerView = App.ChartServiceMetricsAMS_RegionServerBaseView.extend({
+      id: "service-metrics-ambari-metrics-region-server-test",
+      title: 'test-title',
+      ajaxIndex: 'service.metrics.ambari_metrics.region_server.regions',
+      displayName: 'test-display-name',
+      regionServerName: 'test'
+    }).create();
+  });
+
+  describe('#transformToSeries', function () {
+
+    beforeEach(function () {
+      this.result = regionServerView.transformToSeries(jsonData);
+    });
+
+    it('displayName', function () {
+      expect(this.result[0].name === regionServerView.displayName).to.be.true;
+    });
+
+    it('data.length', function () {
+      expect(this.result[0].data.length).to.equal(jsonData.metrics.hbase.regionserver['test'].length);
+    });
+
+    it('y-property', function () {
+      expect(this.result[0].data[0]).to.have.property('y').to.equal(11);
+    });
+
+    it('x-property', function () {
+      expect(this.result[0].data[0]).to.have.property('x').to.equal(1424948261);
+    });
+
   });
+
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/main/service/info/summary_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/summary_test.js b/ambari-web/test/views/main/service/info/summary_test.js
index 66db774..170eb41 100644
--- a/ambari-web/test/views/main/service/info/summary_test.js
+++ b/ambari-web/test/views/main/service/info/summary_test.js
@@ -50,67 +50,113 @@ describe('App.MainServiceInfoSummaryView', function() {
       expect(view.get('servers')).to.be.empty;
     });
 
-    it('if one server exists then first server should have isComma and isAnd property false', function () {
-      view.set('controller.content', Em.Object.create({
-        id: 'ZOOKEEPER',
-        serviceName: 'ZOOKEEPER',
-        hostComponents: [
-          Em.Object.create({
-            displayName: '',
-            isMaster: true
-          })
-        ]
-      }));
-      expect(view.get('servers').objectAt(0).isComma).to.equal(false);
-      expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
+    describe('if one server exists then first server should have isComma and isAnd property false', function () {
+
+      beforeEach(function () {
+        view.set('controller.content', Em.Object.create({
+          id: 'ZOOKEEPER',
+          serviceName: 'ZOOKEEPER',
+          hostComponents: [
+            Em.Object.create({
+              displayName: '',
+              isMaster: true
+            })
+          ]
+        }));
+      });
+
+      it('isComma', function () {
+        expect(view.get('servers').objectAt(0).isComma).to.equal(false);});
+
+      it('isAnd', function () {
+        expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
+      });
     });
 
-    it('if more than one servers exist then first server should have isComma - true and isAnd - false', function () {
-      view.set('controller.content', Em.Object.create({
-        id: 'ZOOKEEPER',
-        serviceName: 'ZOOKEEPER',
-        hostComponents: [
-          Em.Object.create({
-            displayName: '',
-            isMaster: true
-          }),
-          Em.Object.create({
-            displayName: '',
-            isMaster: true
-          })
-        ]
-      }));
-      expect(view.get('servers').objectAt(0).isComma).to.equal(true);
-      expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
-      expect(view.get('servers').objectAt(1).isComma).to.equal(false);
-      expect(view.get('servers').objectAt(1).isAnd).to.equal(false);
+    describe('if more than one servers exist then first server should have isComma - true and isAnd - false', function() {
+
+      beforeEach(function () {
+        view.set('controller.content', Em.Object.create({
+          id: 'ZOOKEEPER',
+          serviceName: 'ZOOKEEPER',
+          hostComponents: [
+            Em.Object.create({
+              displayName: '',
+              isMaster: true
+            }),
+            Em.Object.create({
+              displayName: '',
+              isMaster: true
+            })
+          ]
+        }));
+      });
+
+      it('0 isComma', function () {
+        expect(view.get('servers').objectAt(0).isComma).to.equal(true);
+      });
+
+      it('0 isAnd', function () {
+        expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
+      });
+
+      it('1 isComma', function () {
+        expect(view.get('servers').objectAt(1).isComma).to.equal(false);
+      });
+
+      it('1 isAnd', function () {
+        expect(view.get('servers').objectAt(1).isAnd).to.equal(false);
+      });
+
     });
 
-    it('if more than two servers exist then second server should have isComma - false and isAnd - true', function () {
-      view.set('controller.content', Em.Object.create({
-        id: 'ZOOKEEPER',
-        serviceName: 'ZOOKEEPER',
-        hostComponents: [
-          Em.Object.create({
-            displayName: '',
-            isMaster: true
-          }),
-          Em.Object.create({
-            displayName: '',
-            isMaster: true
-          }),
-          Em.Object.create({
-            displayName: '',
-            isMaster: true
-          })
-        ]
-      }));
-      expect(view.get('servers').objectAt(0).isComma).to.equal(true);
-      expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
-      expect(view.get('servers').objectAt(1).isComma).to.equal(false);
-      expect(view.get('servers').objectAt(1).isAnd).to.equal(true);
-      expect(view.get('servers').objectAt(2).isComma).to.equal(false);
-      expect(view.get('servers').objectAt(2).isAnd).to.equal(false);
+    describe('if more than two servers exist then second server should have isComma - false and isAnd - true', function () {
+
+      beforeEach(function () {
+        view.set('controller.content', Em.Object.create({
+          id: 'ZOOKEEPER',
+          serviceName: 'ZOOKEEPER',
+          hostComponents: [
+            Em.Object.create({
+              displayName: '',
+              isMaster: true
+            }),
+            Em.Object.create({
+              displayName: '',
+              isMaster: true
+            }),
+            Em.Object.create({
+              displayName: '',
+              isMaster: true
+            })
+          ]
+        }));
+      });
+
+      it('0 isComma', function () {
+        expect(view.get('servers').objectAt(0).isComma).to.equal(true);
+      });
+
+      it('0 isAnd', function () {
+        expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
+      });
+
+      it('1 isComma', function () {
+        expect(view.get('servers').objectAt(1).isComma).to.equal(false);
+      });
+
+      it('1 isAnd', function () {
+        expect(view.get('servers').objectAt(1).isAnd).to.equal(true);
+      });
+
+      it('2 isComma', function () {
+        expect(view.get('servers').objectAt(2).isComma).to.equal(false);
+      });
+
+      it('2 isAnd', function () {
+        expect(view.get('servers').objectAt(2).isAnd).to.equal(false);
+      });
+
     });
 
   });
@@ -398,58 +444,84 @@ describe('App.MainServiceInfoSummaryView', function() {
   });
 
   describe("#restartAllStaleConfigComponents", function () {
-    it("trigger restartAllServiceHostComponents", function () {
-      var view = App.MainServiceInfoSummaryView.create({
-        controller: Em.Object.create({
-          content: {
-            serviceName: "HDFS"
-          },
-          getActiveWidgetLayout: Em.K
-        }),
-        service: Em.Object.create({
-          displayName: 'HDFS'
-        })
+
+    describe('trigger restartAllServiceHostComponents', function () {
+      var view;
+      beforeEach(function () {
+        view = App.MainServiceInfoSummaryView.create({
+          controller: Em.Object.create({
+            content: {
+              serviceName: "HDFS"
+            },
+            getActiveWidgetLayout: Em.K
+          }),
+          service: Em.Object.create({
+            displayName: 'HDFS'
+          })
+        });
+        sinon.stub(batchUtils, "restartAllServiceHostComponents", Em.K);
+      });
+
+      afterEach(function () {
+        batchUtils.restartAllServiceHostComponents.restore();
+      });
+
+      it('batch request is started', function () {
+        view.restartAllStaleConfigComponents().onPrimary();
+        expect(batchUtils.restartAllServiceHostComponents.calledOnce).to.equal(true);
       });
-      sinon.stub(batchUtils, "restartAllServiceHostComponents", Em.K);
-      view.restartAllStaleConfigComponents().onPrimary();
-      expect(batchUtils.restartAllServiceHostComponents.calledOnce).to.equal(true);
-      batchUtils.restartAllServiceHostComponents.restore();
+
     });
-    it("trigger check last check point warning before triggering restartAllServiceHostComponents", function () {
-      var view = App.MainServiceInfoSummaryView.create({
-        controller: Em.Object.create({
-          content: {
-            serviceName: "HDFS",
-            hostComponents: [{
-              componentName: 'NAMENODE',
-              workStatus: 'STARTED'
-            }],
-            restartRequiredHostsAndComponents: {
-              "host1": ['NameNode'],
-              "host2": ['DataNode', 'ZooKeeper']
-            }
-          },
-          getActiveWidgetLayout: Em.K
-        }),
-        service: Em.Object.create({
-          displayName: 'HDFS'
-        })
+
+    describe('trigger check last check point warning before triggering restartAllServiceHostComponents', function () {
+
+      var view;
+      var mainServiceItemController;
+
+      beforeEach(function () {
+        view = App.MainServiceInfoSummaryView.create({
+          controller: Em.Object.create({
+            content: {
+              serviceName: "HDFS",
+              hostComponents: [{
+                componentName: 'NAMENODE',
+                workStatus: 'STARTED'
+              }],
+              restartRequiredHostsAndComponents: {
+                "host1": ['NameNode'],
+                "host2": ['DataNode', 'ZooKeeper']
+              }
+            },
+            getActiveWidgetLayout: Em.K
+          }),
+          service: Em.Object.create({
+            displayName: 'HDFS'
+          })
+        });
+        mainServiceItemController = App.MainServiceItemController.create({});
+        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);
+        });
       });
-      var mainServiceItemController = App.MainServiceItemController.create({});
-      sinon.stub(mainServiceItemController, 'checkNnLastCheckpointTime', function() {
-        return true;
+
+      afterEach(function () {
+        mainServiceItemController.checkNnLastCheckpointTime.restore();
+        App.router.get.restore();
       });
-      sinon.stub(App.router, 'get', function(k) {
-        if ('mainServiceItemController' === k) {
-          return mainServiceItemController;
-        }
-        return Em.get(App.router, k);
+
+      it('NN Last CheckPoint is checked', function () {
+        view.restartAllStaleConfigComponents();
+        expect(mainServiceItemController.checkNnLastCheckpointTime.calledOnce).to.equal(true);
       });
-      view.restartAllStaleConfigComponents();
-      expect(mainServiceItemController.checkNnLastCheckpointTime.calledOnce).to.equal(true);
-      mainServiceItemController.checkNnLastCheckpointTime.restore();
-      App.router.get.restore();
+
     });
+
   });
 
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step0_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step0_view_test.js b/ambari-web/test/views/wizard/step0_view_test.js
index 5f350a2..4dc49c4 100644
--- a/ambari-web/test/views/wizard/step0_view_test.js
+++ b/ambari-web/test/views/wizard/step0_view_test.js
@@ -75,14 +75,22 @@ describe('App.WizardStep0ViewClusterNameInput', function () {
   });
 
   describe('#keyPress', function() {
+
+    beforeEach(function () {
+      sinon.spy(view.get('parentView.controller'), 'submit');
+    });
+
+    afterEach(function () {
+      view.get('parentView.controller').submit.restore();
+    });
+
     it('should return true if pressed not Enter', function() {
       expect(view.keyPress({keyCode: 1})).to.equal(true);
+      expect(view.get('parentView.controller').submit.called).to.equal(false);
     });
     it('should submit form if Enter pressed', function() {
-      sinon.spy(view.get('parentView.controller'), 'submit');
       expect(view.keyPress({keyCode: 13})).to.equal(false);
       expect(view.get('parentView.controller').submit.calledOnce).to.equal(true);
-      view.get('parentView.controller').submit.restore();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step10_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step10_view_test.js b/ambari-web/test/views/wizard/step10_view_test.js
index c101613..92668e6 100644
--- a/ambari-web/test/views/wizard/step10_view_test.js
+++ b/ambari-web/test/views/wizard/step10_view_test.js
@@ -28,11 +28,18 @@ describe('App.WizardStep10View', function() {
     });
   });
   describe('#didInsertElement()', function() {
-    it('should call loadStep', function() {
+
+    beforeEach(function () {
       sinon.stub(view.get('controller'), 'loadStep', Em.K);
+    });
+
+    afterEach(function () {
+      view.get('controller').loadStep.restore();
+    });
+
+    it('should call loadStep', function() {
       view.didInsertElement();
       expect(view.get('controller').loadStep.calledOnce).to.equal(true);
-      view.get('controller').loadStep.restore();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step1_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step1_view_test.js b/ambari-web/test/views/wizard/step1_view_test.js
index 497da5e..1cfb7ff 100644
--- a/ambari-web/test/views/wizard/step1_view_test.js
+++ b/ambari-web/test/views/wizard/step1_view_test.js
@@ -169,25 +169,55 @@ describe('App.WizardStep1View', function () {
       expect(view.get('operatingSystems.length')).to.equal(0);
     });
 
-    it('should create repo groups from repo list', function () {
-      controller = App.WizardStep1Controller.create({
-        content: {
-          stacks: App.Stack.find()
-        }
+    describe('should create repo groups from repo list', function () {
+
+      var repositories;
+
+      beforeEach(function () {
+        controller = App.WizardStep1Controller.create({
+          content: {
+            stacks: App.Stack.find()
+          }
+        });
+
+        view = App.WizardStep1View.create({'controller': controller});
+        view.set('$', function () {
+          return Em.Object.create({hide: Em.K, toggle: Em.K});
+        });
+
+        repositories = view.get('allRepositories');
       });
-      view = App.WizardStep1View.create({'controller': controller});
-      view.set('$', function () {
-        return Em.Object.create({hide: Em.K, toggle: Em.K});
+
+      it('operatingSystems.length', function () {
+        expect(view.get('operatingSystems.length')).to.equal(2);
+      });
+
+      it('operatingSystems.0.osType', function () {
+        expect(view.get('operatingSystems')[0].get('osType')).to.equal('redhat5');
+      });
+
+      it('operatingSystems.1.osType', function () {
+        expect(view.get('operatingSystems')[1].get('osType')).to.equal('redhat6');
+      });
+
+      it('operatingSystems.0.isSelected', function () {
+        expect(view.get('operatingSystems')[0].get('isSelected')).to.be.true;
       });
-      var repositories = view.get('allRepositories');
-      expect(view.get('operatingSystems.length')).to.equal(2);
-      expect(view.get('operatingSystems')[0].get('osType')).to.equal('redhat5');
-      expect(view.get('operatingSystems')[1].get('osType')).to.equal('redhat6');
-      expect(view.get('operatingSystems')[0].get('isSelected')).to.be.true;
-      expect(view.get('operatingSystems')[1].get('isSelected')).to.be.true;
-      expect(view.get('operatingSystems')[0].get('repositories')).to.eql([repositories[0], repositories[1]]);
-      expect(view.get('operatingSystems')[1].get('repositories')).to.eql([repositories[2], repositories[3]]);
+
+      it('operatingSystems.1.isSelected', function () {
+        expect(view.get('operatingSystems')[1].get('isSelected')).to.be.true;
+      });
+
+      it('operatingSystems.0.repositories', function () {
+        expect(view.get('operatingSystems')[0].get('repositories')).to.eql([repositories[0], repositories[1]]);
+      });
+
+      it('operatingSystems.1.repositories', function () {
+        expect(view.get('operatingSystems')[1].get('repositories')).to.eql([repositories[2], repositories[3]]);
+      });
+
     });
+
   });
 
   describe('#invalidFormatUrlExist', function () {
@@ -312,12 +342,19 @@ describe('App.WizardStep1View', function () {
   });
 
   describe('#didInsertElement', function () {
-    it('should create tooltip', function () {
+
+    beforeEach(function () {
       sinon.stub($.fn, 'tooltip', Em.K);
+    });
+
+    afterEach(function () {
+      $.fn.tooltip.restore();
+    });
+
+    it('should create tooltip', function () {
       view.set('isRLCollapsed', false);
       view.didInsertElement();
       expect($.fn.tooltip.calledOnce).to.equal(true);
-      $.fn.tooltip.restore();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js b/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
index d49cb7a..50f5f7b 100644
--- a/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
+++ b/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
@@ -53,11 +53,18 @@ describe('App.WizardStep3HostWarningPopupBody', function() {
   });
 
   describe('#showHostsPopup', function() {
-    it('should call App.ModalPopup.show', function() {
+
+    beforeEach(function () {
       sinon.stub(App.ModalPopup, 'show', Em.K);
+    });
+
+    afterEach(function () {
+      App.ModalPopup.show.restore();
+    });
+
+    it('should call App.ModalPopup.show', function() {
       view.showHostsPopup({context: []});
       expect(App.ModalPopup.show.calledOnce).to.equal(true);
-      App.ModalPopup.show.restore();
     });
   });
 
@@ -115,6 +122,15 @@ describe('App.WizardStep3HostWarningPopupBody', function() {
     });
 
     describe('#click', function() {
+
+      beforeEach(function () {
+        sinon.spy(lazyloading, 'run');
+      });
+
+      afterEach(function () {
+        lazyloading.run.restore();
+      });
+
       Em.A([
           {
             isLoaded: false,
@@ -142,7 +158,6 @@ describe('App.WizardStep3HostWarningPopupBody', function() {
               isLoaded: test.isLoaded,
               isLazyLoading: test.isLazyLoading
             });
-            sinon.spy(lazyloading, 'run');
             v.click();
             if (test.e) {
               expect(lazyloading.run.calledOnce).to.equal(true);
@@ -150,7 +165,6 @@ describe('App.WizardStep3HostWarningPopupBody', function() {
             else {
               expect(lazyloading.run.called).to.equal(false);
             }
-            lazyloading.run.restore();
           });
         });
     });
@@ -181,47 +195,40 @@ describe('App.WizardStep3HostWarningPopupBody', function() {
     ];
     beforeEach(function() {
       view.reopen({content: content, warningsByHost: [], hostNamesWithWarnings: ['c', 'd']});
+      this.newContent = view.get('contentInDetails');
     });
     it('should map hosts', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('c d')).to.equal(true);
+      expect(this.newContent.contains('c d')).to.equal(true);
     });
     it('should map firewall warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('n1<br>n2<br>n3')).to.equal(true);
+      expect(this.newContent.contains('n1<br>n2<br>n3')).to.equal(true);
     });
     it('should map fileFolders warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('n4 n5 n6')).to.equal(true);
+      expect(this.newContent.contains('n4 n5 n6')).to.equal(true);
     });
     it('should map process warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('(h1,u1,pid1)')).to.equal(true);
-      expect(newContent.contains('(h2,u1,pid1)')).to.equal(true);
-      expect(newContent.contains('(h2,u2,pid2)')).to.equal(true);
-      expect(newContent.contains('(h3,u1,pid3)')).to.equal(true);
+      expect(this.newContent.contains('(h1,u1,pid1)')).to.equal(true);
+      expect(this.newContent.contains('(h2,u1,pid1)')).to.equal(true);
+      expect(this.newContent.contains('(h2,u2,pid2)')).to.equal(true);
+      expect(this.newContent.contains('(h3,u1,pid3)')).to.equal(true);
     });
     it('should map package warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('n10 n11 n12')).to.equal(true);
+      expect(this.newContent.contains('n10 n11 n12')).to.equal(true);
     });
     it('should map service warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('n13 n14 n15')).to.equal(true);
+      expect(this.newContent.contains('n13 n14 n15')).to.equal(true);
     });
     it('should map user warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('n16 n17 n18')).to.equal(true);
+      expect(this.newContent.contains('n16 n17 n18')).to.equal(true);
     });
     it('should map reverse lookup warnings', function() {
-      var newContent = view.get('contentInDetails');
-      expect(newContent.contains('h1')).to.equal(true);
+      expect(this.newContent.contains('h1')).to.equal(true);
     });
   });
 
   describe('#content', function () {
 
-    it('should return array with warning objects', function () {
+    beforeEach(function () {
       view.set('bodyController', Em.Object.create({
         hostCheckWarnings: [
           {
@@ -333,23 +340,67 @@ describe('App.WizardStep3HostWarningPopupBody', function() {
           }
         ]
       });
-      var content = view.get('content');
-      expect(content.mapProperty('isCollapsed').uniq()).to.eql([true]);
-      expect(content.findProperty('category', 'hostNameResolution').get('warnings')[0].hostsList).
+      this.content = view.get('content');
+    });
+
+    it('isCollapsed', function () {
+      expect(this.content.mapProperty('isCollapsed').uniq()).to.eql([true]);
+    });
+
+    it('hostNameResolution', function () {
+      expect(this.content.findProperty('category', 'hostNameResolution').get('warnings')[0].hostsList).
         to.equal('h0<br>h1<br>h2<br>h3<br>h4<br>h5<br>h5<br>h7<br>h8<br>h9<br> ' + Em.I18n.t('installer.step3.hostWarningsPopup.moreHosts').format(1));
-      expect(content.findProperty('category', 'repositories').get('warnings')[0].hostsList).to.equal('h11<br>h12');
-      expect(content.findProperty('category', 'disk').get('warnings')[0].hostsList).to.equal('h13');
-      expect(content.findProperty('category', 'jdk').get('warnings')[0].hostsList).to.equal('h14');
-      expect(content.findProperty('category', 'thp').get('warnings')[0].hostsList).to.equal('h15');
-      expect(content.findProperty('category', 'firewall').get('warnings').mapProperty('hostsList')).to.eql(['h16', 'h17']);
-      expect(content.findProperty('category', 'process').get('warnings')[0].hostsList).to.equal('h18');
-      expect(content.findProperty('category', 'package').get('warnings')[0].hostsList).to.equal('h19');
-      expect(content.findProperty('category', 'fileFolders').get('warnings')[0].hostsList).to.equal('h20');
-      expect(content.findProperty('category', 'service').get('warnings')[0].hostsList).to.equal('h21');
-      expect(content.findProperty('category', 'user').get('warnings')[0].hostsList).to.equal('h22');
-      expect(content.findProperty('category', 'misc').get('warnings')[0].hostsList).to.equal('h23');
-      expect(content.findProperty('category', 'alternatives').get('warnings')[0].hostsList).to.equal('h24');
-      expect(content.findProperty('category', 'reverseLookup').get('warnings').mapProperty('hostsList')).to.eql([
+    });
+
+    it('repositories', function () {
+      expect(this.content.findProperty('category', 'repositories').get('warnings')[0].hostsList).to.equal('h11<br>h12');
+    });
+
+    it('disk', function () {
+      expect(this.content.findProperty('category', 'disk').get('warnings')[0].hostsList).to.equal('h13');
+    });
+
+    it('jdk', function () {
+      expect(this.content.findProperty('category', 'jdk').get('warnings')[0].hostsList).to.equal('h14');
+    });
+
+    it('thp', function () {
+      expect(this.content.findProperty('category', 'thp').get('warnings')[0].hostsList).to.equal('h15');
+    });
+
+    it('firewall', function () {
+      expect(this.content.findProperty('category', 'firewall').get('warnings').mapProperty('hostsList')).to.eql(['h16', 'h17']);
+    });
+
+    it('process', function () {
+      expect(this.content.findProperty('category', 'process').get('warnings')[0].hostsList).to.equal('h18');});
+
+    it('package', function () {
+      expect(this.content.findProperty('category', 'package').get('warnings')[0].hostsList).to.equal('h19');
+    });
+
+    it('fileFolders', function () {
+      expect(this.content.findProperty('category', 'fileFolders').get('warnings')[0].hostsList).to.equal('h20');
+    });
+
+    it('service', function () {
+      expect(this.content.findProperty('category', 'service').get('warnings')[0].hostsList).to.equal('h21');
+    });
+
+    it('user', function () {
+      expect(this.content.findProperty('category', 'user').get('warnings')[0].hostsList).to.equal('h22');
+    });
+
+    it('misc', function () {
+      expect(this.content.findProperty('category', 'misc').get('warnings')[0].hostsList).to.equal('h23');
+    });
+
+    it('alternatives', function () {
+      expect(this.content.findProperty('category', 'alternatives').get('warnings')[0].hostsList).to.equal('h24');
+    });
+
+    it('reverseLookup', function () {
+      expect(this.content.findProperty('category', 'reverseLookup').get('warnings').mapProperty('hostsList')).to.eql([
         'h25', 'h26', 'h27', 'h28', 'h29', 'h30', 'h31', 'h32', 'h33', 'h34', 'h35<br>h36'
       ]);
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step3_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step3_view_test.js b/ambari-web/test/views/wizard/step3_view_test.js
index 9b74535..bb4c6cb 100644
--- a/ambari-web/test/views/wizard/step3_view_test.js
+++ b/ambari-web/test/views/wizard/step3_view_test.js
@@ -352,14 +352,20 @@ describe('App.WizardStep3View', function () {
   });
 
   describe('#hostBootStatusObserver', function() {
-    it('should call "Em.run.once" three times', function() {
+
+    beforeEach(function () {
       sinon.spy(Em.run, 'once');
       view.hostBootStatusObserver();
-      expect(Em.run.once.calledThrice).to.equal(true);
+    });
+
+    afterEach(function () {
+      Em.run.once.restore();
+    });
+
+    it('should call "Em.run.once" three times', function() {
       expect(Em.run.once.firstCall.args[1]).to.equal('countCategoryHosts');
       expect(Em.run.once.secondCall.args[1]).to.equal('filter');
       expect(Em.run.once.thirdCall.args[1]).to.equal('monitorStatuses');
-      Em.run.once.restore();
     });
   });
 
@@ -397,12 +403,19 @@ describe('App.WizardStep3View', function () {
   });
 
   describe('#watchSelectionOnce', function() {
-    it('should call "Em.run.once" one time', function() {
+
+    beforeEach(function () {
       sinon.spy(Em.run, 'once');
       view.watchSelectionOnce();
+    });
+
+    afterEach(function () {
+      Em.run.once.restore();
+    });
+
+    it('should call "Em.run.once" one time', function() {
       expect(Em.run.once.calledOnce).to.equal(true);
       expect(Em.run.once.firstCall.args[1]).to.equal('watchSelection');
-      Em.run.once.restore();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step5_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step5_view_test.js b/ambari-web/test/views/wizard/step5_view_test.js
index be01771..824d67e 100644
--- a/ambari-web/test/views/wizard/step5_view_test.js
+++ b/ambari-web/test/views/wizard/step5_view_test.js
@@ -89,11 +89,18 @@ describe('App.WizardStep5View', function() {
   });
 
   describe('#didInsertElement', function() {
-    it('should call controller.loadStep', function() {
+
+    beforeEach(function () {
       sinon.stub(view.get('controller'), 'loadStep', Em.K);
+    });
+
+    afterEach(function () {
+      view.get('controller').loadStep.restore();
+    });
+
+    it('should call controller.loadStep', function() {
       view.didInsertElement();
       expect(view.get('controller').loadStep.calledOnce).to.equal(true);
-      view.get('controller').loadStep.restore();
     });
   });
 
@@ -361,15 +368,21 @@ describe('App.InputHostView', function() {
       }
     ]);
 
+    beforeEach(function () {
+      sinon.stub(view, 'initContent', Em.K);
+    });
+
+    afterEach(function () {
+      view.initContent.restore();
+    });
+
     tests.forEach(function(test) {
       it(test.m, function() {
         view.set('content', test.content);
         view.set('component', {component_name: test.componentName});
         view.set('controller.componentToRebalance', test.componentToRebalance);
-        sinon.stub(view, 'initContent', Em.K);
         view.rebalanceComponentHostsOnce();
         expect(view.initContent.calledOnce).to.equal(test.e.initContent);
-        view.initContent.restore();
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step6_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step6_view_test.js b/ambari-web/test/views/wizard/step6_view_test.js
index b5d2f43..7a4dc9f 100644
--- a/ambari-web/test/views/wizard/step6_view_test.js
+++ b/ambari-web/test/views/wizard/step6_view_test.js
@@ -166,25 +166,31 @@ describe('App.WizardStep6HostView', function() {
   });
 
   describe('#didInsertElement', function() {
+
+    var data = [];
+
     beforeEach(function() {
       sinon.stub(App, 'popover', Em.K);
+      sinon.stub(view.get('controller'), 'getMasterComponentsForHost', function() {return data;});
     });
+
     afterEach(function() {
       App.popover.restore();
+      view.get('controller').getMasterComponentsForHost.restore();
     });
+
     it('should create popover if not controller.isMasters', function() {
-      sinon.stub(view.get('controller'), 'getMasterComponentsForHost', function() {return [{}, {}];});
+      data = [{}, {}];
       view.set('controller.isMasters', false);
       view.didInsertElement();
       expect(App.popover.calledOnce).to.equal(true);
-      view.get('controller').getMasterComponentsForHost.restore();
     });
+
     it('should create popover even if controller.getMasterComponentsForHost is an empty array', function() {
-      sinon.stub(view.get('controller'), 'getMasterComponentsForHost', function() {return [];});
+      data = [{}];
       view.set('controller.isMasters', true);
       view.didInsertElement();
       expect(App.popover.calledOnce).to.equal(true);
-      view.get('controller').getMasterComponentsForHost.restore();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8acfcd89/ambari-web/test/views/wizard/step8_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step8_view_test.js b/ambari-web/test/views/wizard/step8_view_test.js
index 3f8a605..bdb71dc 100644
--- a/ambari-web/test/views/wizard/step8_view_test.js
+++ b/ambari-web/test/views/wizard/step8_view_test.js
@@ -30,23 +30,37 @@ describe('App.WizardStep8View', function() {
   });
 
   describe('#didInsertElement', function() {
-    it('should call loadStep', function() {
+
+    beforeEach(function () {
       view.set('controller', Em.Object.create({
         loadStep: Em.K
       }));
       sinon.spy(view.get('controller'), 'loadStep');
+    });
+
+    afterEach(function () {
+      view.get('controller').loadStep.restore();
+    });
+
+    it('should call loadStep', function() {
       view.didInsertElement();
       expect(view.get('controller').loadStep.calledOnce).to.equal(true);
-      view.get('controller').loadStep.restore();
     });
   });
 
   describe('#printReview', function() {
-    it('should call jqprint', function() {
+
+    beforeEach(function() {
       sinon.stub($.fn, 'jqprint', Em.K);
+    });
+
+    afterEach(function () {
+      $.fn.jqprint.restore();
+    });
+
+    it('should call jqprint', function() {
       view.printReview();
       expect($.fn.jqprint.calledOnce).to.equal(true);
-      $.fn.jqprint.restore();
     });
   });