ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject git commit: AMBARI-5694. Unit test for step views. (onechiporenko)
Date Wed, 07 May 2014 13:06:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 35bf069ba -> e702b3175


AMBARI-5694. Unit test for step views. (onechiporenko)


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

Branch: refs/heads/trunk
Commit: e702b31753d3f581f747cbe95c0bc64036d92504
Parents: 35bf069
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Wed May 7 15:42:50 2014 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Wed May 7 16:06:11 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/views/wizard/step2_view.js       |   1 +
 ambari-web/app/views/wizard/step5_view.js       |   3 +-
 ambari-web/test/views/wizard/step0_view_test.js |  56 +-
 ambari-web/test/views/wizard/step1_view_test.js | 622 +++++++++++++++++--
 ambari-web/test/views/wizard/step2_view_test.js | 129 ++++
 ambari-web/test/views/wizard/step3_view_test.js |  46 ++
 ambari-web/test/views/wizard/step5_view_test.js |  69 ++
 7 files changed, 883 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/ambari-web/app/views/wizard/step2_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step2_view.js b/ambari-web/app/views/wizard/step2_view.js
index d0133a3..e227e8c 100644
--- a/ambari-web/app/views/wizard/step2_view.js
+++ b/ambari-web/app/views/wizard/step2_view.js
@@ -70,6 +70,7 @@ App.WizardStep2View = Em.View.extend({
    * TODO: incupsulate it inside of App.SshKeyFileUploader
    */
   isFileApi: function () {
+    /* istanbul ignore next */
     return window.File && window.FileReader && window.FileList;
   }.property(),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/ambari-web/app/views/wizard/step5_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step5_view.js b/ambari-web/app/views/wizard/step5_view.js
index 9a43a99..5a55e0f 100644
--- a/ambari-web/app/views/wizard/step5_view.js
+++ b/ambari-web/app/views/wizard/step5_view.js
@@ -116,15 +116,14 @@ App.SelectHostView = Em.Select.extend({
     }
     return hosts;
   },
+
   /**
    * On click start lazy loading
    * @method click
    */
   click: function () {
     var source = [];
-    var componentName = this.get('componentName');
     var availableHosts = this.getAvailableHosts();
-    var selectedHost = this.get('selectedHost');
 
     if (!this.get('isLoaded') && this.get('isLazyLoading')) {
       //filter out hosts, which already pushed in select

http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/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 22acdfa..5f350a2 100644
--- a/ambari-web/test/views/wizard/step0_view_test.js
+++ b/ambari-web/test/views/wizard/step0_view_test.js
@@ -20,24 +20,70 @@ var App = require('app');
 require('views/wizard/step0_view');
 
 var view, controller = Em.Object.create({
-  clusterNameError: ''
+  clusterNameError: '',
+  loadStep: Em.K
 });
 
 describe('App.WizardStep0View', function () {
 
-  beforeEach(function() {
+  beforeEach(function () {
     view = App.WizardStep0View.create({'controller': controller});
   });
 
-  describe('#onError', function() {
-    it('should be true if clusterNameError appears', function() {
+  describe('#onError', function () {
+    it('should be true if clusterNameError appears', function () {
       controller.set('clusterNameError', 'ERROR');
       expect(view.get('onError')).to.equal(true);
     });
-    it('should be false if clusterNameError doesn\'t appears', function() {
+    it('should be false if clusterNameError doesn\'t appears', function () {
       controller.set('clusterNameError', '');
       expect(view.get('onError')).to.equal(false);
     });
   });
 
+  describe('#didInsertElement', function () {
+    beforeEach(function () {
+      sinon.stub(App, 'popover', Em.K);
+      sinon.spy(view.get('controller'), 'loadStep');
+    });
+    afterEach(function () {
+      App.popover.restore();
+      view.get('controller').loadStep.restore();
+    });
+    it('should call loadStep', function () {
+      view.didInsertElement();
+      expect(view.get('controller').loadStep.calledOnce).to.equal(true);
+    });
+    it('should create popover', function () {
+      view.didInsertElement();
+      expect(App.popover.calledOnce).to.equal(true);
+    });
+  });
+
 });
+
+describe('App.WizardStep0ViewClusterNameInput', function () {
+
+  beforeEach(function() {
+    view = App.WizardStep0ViewClusterNameInput.create({
+      parentView: Em.Object.create({
+        controller: Em.Object.create({
+          submit: Em.K
+        })
+      })
+    });
+  });
+
+  describe('#keyPress', function() {
+    it('should return true if pressed not Enter', function() {
+      expect(view.keyPress({keyCode: 1})).to.equal(true);
+    });
+    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();
+    });
+  });
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/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 68af264..8fe9880 100644
--- a/ambari-web/test/views/wizard/step1_view_test.js
+++ b/ambari-web/test/views/wizard/step1_view_test.js
@@ -29,22 +29,25 @@ var controller = Em.Object.create({
 
 describe('App.WizardStep1View', function () {
 
-  beforeEach(function() {
+  beforeEach(function () {
     view = App.WizardStep1View.create({'controller': controller});
+    view.set('$', function () {
+      return Em.Object.create({hide: Em.K, toggle: Em.K});
+    });
   });
 
-  describe('#osTypeToGroup', function() {
+  describe('#osTypeToGroup', function () {
 
     var tests = Em.A([
-      {os:'redhat5', e: 0},
+      {os: 'redhat5', e: 0},
       {os: 'redhat6', e: 1},
       {os: 'suse11', e: 2},
       {os: 'debian12', e: 3},
       {os: 'bulgen', e: -1}
     ]);
 
-    tests.forEach(function(test) {
-      it(test.os, function() {
+    tests.forEach(function (test) {
+      it(test.os, function () {
         expect(view.osTypeToGroup(test.os)).to.equal(test.e);
       });
     });
@@ -61,33 +64,45 @@ describe('App.WizardStep1View', function () {
       {type: -1, e: []}
     ]);
 
-    tests.forEach(function(test) {
-      it(test.type, function() {
+    tests.forEach(function (test) {
+      it(test.type, function () {
         expect(view.groupToOsType(test.type)).to.eql(test.e);
       });
     });
 
   });
 
-  describe('#emptyRepoExist', function() {
+  describe('#emptyRepoExist', function () {
 
     var tests = Em.A([
       {
-        allRepositoriesGroup: [{'empty-error': false},{'empty-error': false},{'empty-error':
false}],
+        allRepositoriesGroup: [
+          {'empty-error': false},
+          {'empty-error': false},
+          {'empty-error': false}
+        ],
         e: false
       },
       {
-        allRepositoriesGroup: [{'empty-error': true},{'empty-error': false},{'empty-error':
false}],
+        allRepositoriesGroup: [
+          {'empty-error': true},
+          {'empty-error': false},
+          {'empty-error': false}
+        ],
         e: true
       },
       {
-        allRepositoriesGroup: [{'empty-error': true},{'empty-error': true},{'empty-error':
true}],
+        allRepositoriesGroup: [
+          {'empty-error': true},
+          {'empty-error': true},
+          {'empty-error': true}
+        ],
         e: true
       }
     ]);
 
-    tests.forEach(function(test) {
-      it(test.allRepositoriesGroup.mapProperty('empty-error').join(', '), function() {
+    tests.forEach(function (test) {
+      it(test.allRepositoriesGroup.mapProperty('empty-error').join(', '), function () {
         view.set('allRepositoriesGroup', test.allRepositoriesGroup);
         expect(view.get('emptyRepoExist')).to.equal(test.e);
       });
@@ -95,25 +110,37 @@ describe('App.WizardStep1View', function () {
 
   });
 
-  describe('#allRepoUnchecked', function() {
+  describe('#allRepoUnchecked', function () {
 
     var tests = Em.A([
       {
-        allRepositoriesGroup: [{'checked': false},{'checked': false},{'checked': false}],
+        allRepositoriesGroup: [
+          {'checked': false},
+          {'checked': false},
+          {'checked': false}
+        ],
         e: true
       },
       {
-        allRepositoriesGroup: [{'checked': true},{'checked': false},{'checked': false}],
+        allRepositoriesGroup: [
+          {'checked': true},
+          {'checked': false},
+          {'checked': false}
+        ],
         e: false
       },
       {
-        allRepositoriesGroup: [{'checked': true},{'checked': true},{'checked': true}],
+        allRepositoriesGroup: [
+          {'checked': true},
+          {'checked': true},
+          {'checked': true}
+        ],
         e: false
       }
     ]);
 
-    tests.forEach(function(test) {
-      it(test.allRepositoriesGroup.mapProperty('checked').join(', '), function() {
+    tests.forEach(function (test) {
+      it(test.allRepositoriesGroup.mapProperty('checked').join(', '), function () {
         view.set('allRepositoriesGroup', test.allRepositoriesGroup);
         expect(view.get('allRepoUnchecked')).to.equal(test.e);
       });
@@ -121,7 +148,7 @@ describe('App.WizardStep1View', function () {
 
   });
 
-  describe('#stacks', function() {
+  describe('#stacks', function () {
 
     var tests = Em.A([
       {
@@ -145,8 +172,8 @@ describe('App.WizardStep1View', function () {
       }
     ]);
 
-    tests.forEach(function(test) {
-      it(test.m, function() {
+    tests.forEach(function (test) {
+      it(test.m, function () {
         view.set('controller.content.stacks', test.stacks);
         var stacks = view.get('stacks');
         expect(stacks.mapProperty('name')).to.eql(test.e.names);
@@ -156,7 +183,7 @@ describe('App.WizardStep1View', function () {
 
   });
 
-  describe('#isSubmitDisabled', function() {
+  describe('#isSubmitDisabled', function () {
 
     var tests = Em.A([
       {
@@ -209,8 +236,8 @@ describe('App.WizardStep1View', function () {
       }
     ]);
 
-    tests.forEach(function(test) {
-      it(test.emptyRepoExist.toString() + ' ' + test.allRepoUnchecked.toString() + ' ' +
test.invalidUrlExist.toString(), function() {
+    tests.forEach(function (test) {
+      it(test.emptyRepoExist.toString() + ' ' + test.allRepoUnchecked.toString() + ' ' +
test.invalidUrlExist.toString(), function () {
         view = App.WizardStep1View.create();
         view.reopen({
           emptyRepoExist: test.emptyRepoExist,
@@ -223,7 +250,7 @@ describe('App.WizardStep1View', function () {
 
   });
 
-  describe('#invalidUrlExist', function() {
+  describe('#invalidUrlExist', function () {
     var tests = Em.A([
       {
         stacks: [Em.Object.create({isSelected: true, invalidCnt: 1})],
@@ -250,8 +277,8 @@ describe('App.WizardStep1View', function () {
         e: false
       }
     ]);
-    tests.forEach(function(test) {
-      it(test.m, function() {
+    tests.forEach(function (test) {
+      it(test.m, function () {
         view.set('controller.content.stacks', test.stacks);
         view.set('allRepositoriesGroup', test.allRepositoriesGroup);
         expect(view.get('invalidUrlExist')).to.equal(test.e);
@@ -259,40 +286,563 @@ describe('App.WizardStep1View', function () {
     });
   });
 
-  describe('#totalErrorCnt', function() {
+  describe('#totalErrorCnt', function () {
     var tests = Em.A([
       {
-        allRepositoriesGroup: [{checked:false}],
+        allRepositoriesGroup: [
+          {checked: false}
+        ],
         m: 'allRepoUnchecked',
         e: 1
       },
       {
-        allRepositoriesGroup: [{checked:true, 'empty-error': true}, {checked:false, 'empty-error':
true}],
+        allRepositoriesGroup: [
+          {checked: true, 'empty-error': true},
+          {checked: false, 'empty-error': true}
+        ],
         m: 'two with empty-error',
         e: 2
       },
       {
-        allRepositoriesGroup: [{checked:true, 'validation': 'icon-exclamation-sign'}, {checked:false,
'validation': 'icon-exclamation-sign'}],
+        allRepositoriesGroup: [
+          {checked: true, 'validation': 'icon-exclamation-sign'},
+          {checked: false, 'validation': 'icon-exclamation-sign'}
+        ],
         m: 'two with validation="icon-exclamation-sign"',
         e: 2
       },
       {
-        allRepositoriesGroup: [{checked:true, 'empty-error': true, 'validation': 'icon-exclamation-sign'},
{checked:false, 'empty-error': true, 'validation': 'icon-exclamation-sign'}],
+        allRepositoriesGroup: [
+          {checked: true, 'empty-error': true, 'validation': 'icon-exclamation-sign'},
+          {checked: false, 'empty-error': true, 'validation': 'icon-exclamation-sign'}
+        ],
         m: 'two with empty-error, two with validation="icon-exclamation-sign"',
         e: 4
       },
       {
-        allRepositoriesGroup: [{checked:true}],
+        allRepositoriesGroup: [
+          {checked: true}
+        ],
         m: 'no errors/warnings etc',
         e: 0
       }
     ]);
-    tests.forEach(function(test) {
-      it(test.m, function() {
+    tests.forEach(function (test) {
+      it(test.m, function () {
         view.set('allRepositoriesGroup', test.allRepositoriesGroup);
         expect(view.get('totalErrorCnt')).to.equal(test.e);
       });
     });
   });
 
+  describe('#didInsertElement', function () {
+    it('should create tooltip', function () {
+      sinon.stub($.fn, 'tooltip', Em.K);
+      view.set('isRLCollapsed', false);
+      view.didInsertElement();
+      expect($.fn.tooltip.calledOnce).to.equal(true);
+      $.fn.tooltip.restore();
+    });
+  });
+
+  describe('#stackRadioButton', function () {
+
+    var v;
+    beforeEach(function () {
+      v = view.get('stackRadioButton').create({
+        content: Em.Object.create({
+          name: ''
+        }),
+        controller: Em.Object.create({
+          content: Em.Object.create({
+            stacks: []
+          })
+        })
+      });
+    });
+
+    describe('#checked', function () {
+      it('should be equal content.isSelected', function () {
+        v.set('content.isSelected', true);
+        expect(v.get('checked')).to.equal(true);
+        v.set('content.isSelected', false);
+        expect(v.get('checked')).to.equal(false);
+      });
+    });
+
+    describe('#click', function () {
+      it('should select proper stack', function () {
+        v.set('controller.content.stacks', Em.A([Em.Object.create({name: 'n-1'}), Em.Object.create({name:
'n-2'}), Em.Object.create({name: 'n-3'})]));
+        v.set('content.name', 'n 2');
+        v.click();
+        expect(v.get('controller.content.stacks').getEach('isSelected')).to.eql([false, true,
false]);
+      });
+    });
+
+  });
+
+  describe('#popoverView', function () {
+
+    var v;
+    beforeEach(function () {
+      v = view.get('popoverView').create();
+      sinon.stub(App, 'popover', Em.K);
+    });
+
+    afterEach(function () {
+      App.popover.restore();
+    });
+
+    describe('#didInsertElement', function () {
+      it('should create popover', function () {
+        v.didInsertElement();
+        expect(App.popover.calledOnce).to.equal(true);
+      });
+    });
+
+  });
+
+  describe('#onToggleBlock', function () {
+    it('should toggle isRLCollapsed', function () {
+      view.set('isRLCollapsed', true);
+      view.onToggleBlock();
+      expect(view.get('isRLCollapsed')).to.equal(false);
+      view.onToggleBlock();
+      expect(view.get('isRLCollapsed')).to.equal(true);
+    });
+  });
+
+  describe('#setGroupByOs', function () {
+    Em.A([
+        {
+          allGroupsCheckbox: [true, false, true],
+          groupNumber: 1,
+          m: 'should update group',
+          os: {
+            baseUrl: 'baseUrl',
+            latestBaseUrl: 'latestBaseUrl',
+            defaultBaseUrl: 'defaultBaseUrl',
+            validation: 'icon-exclamation-sign',
+            errorTitle: 'errorTitle',
+            errorContent: 'errorContent'
+          },
+          e: {
+            'checked': false,
+            'baseUrl': 'baseUrl',
+            'latestBaseUrl': 'latestBaseUrl',
+            'defaultBaseUrl': 'defaultBaseUrl',
+            'empty-error': false,
+            'invalid-error': true,
+            'validation': 'icon-exclamation-sign',
+            'undo': true,
+            'clearAll': 'baseUrl',
+            'errorTitle': 'errorTitle',
+            'errorContent': 'errorContent',
+            'group-number': 1
+          }
+        },
+        {
+          allGroupsCheckbox: [true, false, true],
+          groupNumber: 0,
+          m: 'should update group (2)',
+          os: {
+            baseUrl: '',
+            latestBaseUrl: 'latestBaseUrl',
+            defaultBaseUrl: 'defaultBaseUrl',
+            validation: 'validation',
+            errorTitle: 'errorTitle',
+            errorContent: 'errorContent'
+          },
+          e: {
+            'checked': true,
+            'baseUrl': '',
+            'latestBaseUrl': 'latestBaseUrl',
+            'defaultBaseUrl': 'defaultBaseUrl',
+            'empty-error': true,
+            'invalid-error': false,
+            'validation': 'validation',
+            'undo': true,
+            'clearAll': '',
+            'errorTitle': 'errorTitle',
+            'errorContent': 'errorContent',
+            'group-number': 0
+          }
+        },
+        {
+          allGroupsCheckbox: [true, false, true],
+          groupNumber: 0,
+          m: 'should update group (3)',
+          os: {
+            baseUrl: 'latestBaseUrl',
+            latestBaseUrl: 'latestBaseUrl',
+            defaultBaseUrl: 'defaultBaseUrl',
+            validation: 'validation',
+            errorTitle: 'errorTitle',
+            errorContent: 'errorContent'
+          },
+          e: {
+            'checked': true,
+            'baseUrl': 'latestBaseUrl',
+            'latestBaseUrl': 'latestBaseUrl',
+            'defaultBaseUrl': 'defaultBaseUrl',
+            'empty-error': false,
+            'invalid-error': false,
+            'validation': 'validation',
+            'undo': false,
+            'clearAll': 'latestBaseUrl',
+            'errorTitle': 'errorTitle',
+            'errorContent': 'errorContent',
+            'group-number': 0
+          }
+        }
+      ]).forEach(function (test) {
+        it(test.m, function () {
+          var group = Em.Object.create({});
+          view.set('allGroupsCheckbox', test.allGroupsCheckbox);
+          view.setGroupByOs(group, test.os, test.groupNumber);
+          Em.keys(test.e).forEach(function (k) {
+            expect(group.get(k)).to.equal(test.e[k]);
+          });
+        });
+      });
+  });
+
+  describe('#updateByCheckbox', function () {
+
+    it('shouldn\'t do nothing if no stack selected', function () {
+      var groups = [
+        {},
+        {},
+        {}
+      ];
+      view.reopen({
+        allRepositoriesGroup: groups,
+        controller: {
+          content: {
+            stacks: [
+              {isSelected: false}
+            ]
+          }
+        }
+      });
+      view.updateByCheckbox();
+      view.get('allRepositoriesGroup').forEach(function(g) {
+        expect(g).to.eql({});
+      });
+    });
+
+    it('target group isn\'t checked', function() {
+      view.reopen({
+        allGroupsCheckbox: [true],
+        allRepositoriesGroup: [
+          Em.Object.create({
+            'group-number': 0,
+            checked: false
+          })
+        ],
+        controller: {
+          content: {
+            stacks: [
+              {
+                isSelected: true,
+                operatingSystems: [
+                  {
+                    osType: 'redhat5',
+                    baseUrl: 'baseUrl',
+                    latestBaseUrl: 'latestBaseUrl',
+                    validation: '',
+                    selected: ''
+                  }
+                ]
+              }
+            ]
+          }
+        }
+      });
+      view.updateByCheckbox();
+      var os = view.get('controller.content.stacks')[0].operatingSystems[0],
+        targetGroup = view.get('allRepositoriesGroup.firstObject');
+      expect(os.baseUrl).to.equal(os.latestBaseUrl);
+      expect(os.selected).to.equal(false);
+      expect(os.validation).to.be.null;
+      expect(view.get('allGroupsCheckbox')).to.eql([false]);
+      expect(targetGroup.get('baseUrl')).to.equal('latestBaseUrl');
+      expect(targetGroup.get('latestBaseUrl')).to.equal('latestBaseUrl');
+      expect(targetGroup.get('undo')).to.equal(false);
+      expect(targetGroup.get('invalid-error')).to.equal(false);
+      expect(targetGroup.get('clearAll')).to.equal(false);
+      expect(targetGroup.get('empty-error')).to.equal(false);
+      expect(targetGroup.get('validation')).to.be.null;
+    });
+
+    it('target group is checked, skipValidationChecked = true', function() {
+      view.reopen({
+        allGroupsCheckbox: [false],
+        skipValidationChecked: true,
+        allRepositoriesGroup: [
+          Em.Object.create({
+            'group-number': 0,
+            checked: true,
+            baseUrl: ''
+          })
+        ],
+        controller: {
+          content: {
+            stacks: [
+              {
+                isSelected: true,
+                operatingSystems: [
+                  {
+                    osType: 'redhat5',
+                    baseUrl: 'baseUrl',
+                    latestBaseUrl: 'latestBaseUrl',
+                    validation: '',
+                    selected: ''
+                  }
+                ]
+              }
+            ]
+          }
+        }
+      });
+      view.updateByCheckbox();
+      var os = view.get('controller.content.stacks')[0].operatingSystems[0],
+        targetGroup = view.get('allRepositoriesGroup.firstObject');
+      expect(os.selected).to.equal(true);
+      expect(os.skipValidation).to.equal(true);
+      expect(view.get('allGroupsCheckbox')).to.eql([true]);
+      expect(targetGroup.get('invalid-error')).to.equal(false);
+      expect(targetGroup.get('empty-error')).to.equal(true);
+      expect(targetGroup.get('clearAll')).to.equal('');
+      expect(targetGroup.get('validation')).to.be.null;
+    });
+
+  });
+
+  describe('#clearGroupLocalRepository', function() {
+    it('should be proxy for doActionForGroupLocalRepository', function() {
+      sinon.stub(view, 'doActionForGroupLocalRepository', Em.K);
+      view.clearGroupLocalRepository({});
+      expect(view.doActionForGroupLocalRepository.calledWith({}, '')).to.equal(true);
+      view.doActionForGroupLocalRepository.restore();
+    });
+  });
+
+  describe('#undoGroupLocalRepository', function() {
+    it('should be proxy for doActionForGroupLocalRepository', function() {
+      sinon.stub(view, 'doActionForGroupLocalRepository', Em.K);
+      view.undoGroupLocalRepository({});
+      expect(view.doActionForGroupLocalRepository.calledWith({}, 'latestBaseUrl')).to.equal(true);
+      view.doActionForGroupLocalRepository.restore();
+    });
+  });
+
+  describe('#doActionForGroupLocalRepository', function() {
+
+    beforeEach(function() {
+      sinon.stub(view, 'loadRepositories', Em.K);
+    });
+
+    afterEach(function() {
+      view.loadRepositories.restore();
+    });
+
+    it('should update OS in selected stack', function() {
+      var event = {context: Em.Object.create({'group-number': 0})};
+      view.reopen({
+        allGroupsCheckbox: [true],
+        allRepositoriesGroup: [
+          Em.Object.create({
+            'group-number': 0,
+            checked: false
+          })
+        ],
+        controller: {
+          content: {
+            stacks: [
+              {
+                isSelected: true,
+                operatingSystems: [
+                  {
+                    osType: 'redhat5',
+                    baseUrl: 'baseUrl',
+                    latestBaseUrl: 'latestBaseUrl',
+                    validation: '',
+                    selected: ''
+                  }
+                ]
+              }
+            ]
+          }
+        }
+      });
+      view.doActionForGroupLocalRepository(event, '');
+      var os = view.get('controller.content.stacks')[0].operatingSystems[0];
+      expect(os.baseUrl).to.equal('');
+      expect(os.validation).to.be.null;
+      expect(view.loadRepositories.calledOnce).to.equal(true);
+    });
+
+    it('should update OS in selected stack (2)', function() {
+      var event = {context: Em.Object.create({'group-number': 0})};
+      view.reopen({
+        allGroupsCheckbox: [true],
+        allRepositoriesGroup: [
+          Em.Object.create({
+            'group-number': 0,
+            checked: false
+          })
+        ],
+        controller: {
+          content: {
+            stacks: [
+              {
+                isSelected: true,
+                operatingSystems: [
+                  {
+                    osType: 'redhat5',
+                    baseUrl: 'baseUrl',
+                    latestBaseUrl: 'latestBaseUrl',
+                    validation: '',
+                    selected: ''
+                  }
+                ]
+              }
+            ]
+          }
+        }
+      });
+      view.doActionForGroupLocalRepository(event, 'latestBaseUrl');
+      var os = view.get('controller.content.stacks')[0].operatingSystems[0];
+      expect(os.baseUrl).to.equal('latestBaseUrl');
+      expect(os.validation).to.be.null;
+      expect(view.loadRepositories.calledOnce).to.equal(true);
+    });
+
+  });
+
+  describe('#editGroupLocalRepository', function() {
+
+    it('should update os and group', function() {
+      view.reopen({
+        allGroupsCheckbox: [true],
+        allRepositoriesGroup: [
+          Em.Object.create({
+            'group-number': 0,
+            checked: false,
+            baseUrl: 'b1'
+          })
+        ],
+        controller: {
+          content: {
+            stacks: [
+              {
+                isSelected: true,
+                operatingSystems: [
+                  {
+                    osType: 'redhat5',
+                    baseUrl: 'baseUrl',
+                    latestBaseUrl: 'latestBaseUrl',
+                    validation: '',
+                    selected: ''
+                  }
+                ]
+              }
+            ]
+          }
+        }
+      });
+      view.editGroupLocalRepository();
+      var os = view.get('controller.content.stacks')[0].operatingSystems[0],
+        targetGroup = view.get('allRepositoriesGroup.firstObject');
+      expect(os.baseUrl).to.equal(targetGroup.get('baseUrl'));
+      expect(os.validation).to.be.null;
+
+
+      expect(targetGroup.get('undo')).to.equal(true);
+      expect(targetGroup.get('invalid-error')).to.equal(false);
+      expect(targetGroup.get('empty-error')).to.equal(false);
+      expect(targetGroup.get('validation')).to.be.null;
+    });
+
+  });
+
+  describe('#loadRepositories', function() {
+    beforeEach(function() {
+      sinon.stub(view, 'setGroupByOs', Em.K);
+      sinon.stub(view, 'updateByCheckbox', Em.K);
+      sinon.stub(view, 'editGroupLocalRepository', Em.K);
+      sinon.stub(App, 'get', function(k) {
+        if('supports.ubuntu' == k) return true;
+        return Em.get(App, k);
+      });
+    });
+    afterEach(function() {
+      view.setGroupByOs.restore();
+      view.updateByCheckbox.restore();
+      view.editGroupLocalRepository.restore();
+      App.get.restore();
+    });
+    Em.A([
+        {
+          osType: 'redhat5',
+          e: {
+            i: 0,
+            o: 'Red Hat 5'
+          }
+        },
+        {
+          osType: 'redhat6',
+          e: {
+            i: 1,
+            o: 'Red Hat 6'
+          }
+        },
+        {
+          osType: 'suse11',
+          e: {
+            i: 2,
+            o: 'SLES 11'
+          }
+        },
+        {
+          osType: 'debian12',
+          e: {
+            i: 3,
+            o: 'Ubuntu 12'
+          }
+        }
+      ]).forEach(function (test) {
+        it(test.osType, function () {
+          view.reopen({
+            allGroupsCheckbox: [true],
+            allRepositoriesGroup: [
+              Em.Object.create({
+                'group-number': 0,
+                checked: false,
+                baseUrl: 'b1'
+              })
+            ],
+            controller: {
+              content: {
+                stacks: [
+                  {
+                    isSelected: true,
+                    operatingSystems: [
+                      {
+                        osType: test.osType,
+                        baseUrl: 'baseUrl'
+                      }
+                    ]
+                  }
+                ]
+              }
+            }
+          });
+          view.loadRepositories();
+          expect(view.get('allRepositoriesGroup')[test.e.i][0].get('osType')).to.equal(test.e.o);
+        });
+      });
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/ambari-web/test/views/wizard/step2_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step2_view_test.js b/ambari-web/test/views/wizard/step2_view_test.js
index a048f5d..47db377 100644
--- a/ambari-web/test/views/wizard/step2_view_test.js
+++ b/ambari-web/test/views/wizard/step2_view_test.js
@@ -38,4 +38,133 @@ describe('App.WizardStep0View', function () {
     });
   });
 
+  describe('#didInsertElement', function() {
+    beforeEach(function () {
+      sinon.stub(App, 'popover', Em.K);
+      view.set('controller.hostsError', 'some text');
+      view.set('controller.sshKeyError', 'some text');
+    });
+    afterEach(function () {
+      App.popover.restore();
+    });
+    it('should clean hostsError', function () {
+      view.didInsertElement();
+      expect(view.get('controller.hostsError')).to.be.null;
+    });
+    it('should clean sshKeyError', function () {
+      view.didInsertElement();
+      expect(view.get('controller.sshKeyError')).to.be.null;
+    });
+    it('should create popover', function () {
+      view.didInsertElement();
+      expect(App.popover.calledOnce).to.equal(true);
+    });
+  });
+
+  describe('#providingSSHKeyRadioButton', function() {
+    var v;
+
+    beforeEach(function() {
+      v = view.get('providingSSHKeyRadioButton').create({
+        controller: Em.Object.create({
+          content: {
+            installOptions: {
+              useSsh: true,
+              manualInstall: true
+            }
+          }
+        })
+      });
+    });
+
+    describe('#checked', function() {
+      it('should be equal to controller.content.installOptions.useSsh', function () {
+        v.set('controller.content.installOptions.useSsh', false);
+        expect(v.get('checked')).to.equal(false);
+        v.set('controller.content.installOptions.useSsh', true);
+        expect(v.get('checked')).to.equal(true);
+      });
+    });
+
+    describe('#click', function() {
+      it('should update controller.content.installOptions.useSsh', function () {
+        v.set('controller.content.installOptions.useSsh', false);
+        v.click();
+        expect(v.get('controller.content.installOptions.useSsh')).to.equal(true);
+      });
+      it('should update controller.content.installOptions.manualInstall', function () {
+        v.set('controller.content.installOptions.manualInstall', true);
+        v.click();
+        expect(v.get('controller.content.installOptions.manualInstall')).to.equal(false);
+      });
+    });
+
+  });
+
+  describe('#manualRegistrationRadioButton', function() {
+    var v;
+
+    beforeEach(function() {
+      v = view.get('manualRegistrationRadioButton').create({
+        controller: Em.Object.create({
+          content: {
+            installOptions: {
+              useSsh: true,
+              manualInstall: true
+            }
+          }
+        })
+      });
+    });
+
+    describe('#checked', function() {
+      it('should be equal to controller.content.installOptions.manualInstall', function ()
{
+        v.set('controller.content.installOptions.manualInstall', false);
+        expect(v.get('checked')).to.equal(false);
+        v.set('controller.content.installOptions.manualInstall', true);
+        expect(v.get('checked')).to.equal(true);
+      });
+    });
+
+    describe('#click', function() {
+      it('should update controller.content.installOptions.useSsh', function () {
+        v.set('controller.content.installOptions.useSsh', true);
+        v.click();
+        expect(v.get('controller.content.installOptions.useSsh')).to.equal(false);
+      });
+      it('should update controller.content.installOptions.manualInstall', function () {
+        v.set('controller.content.installOptions.manualInstall', false);
+        v.click();
+        expect(v.get('controller.content.installOptions.manualInstall')).to.equal(true);
+      });
+    });
+
+  });
+
+  describe('#textFieldView', function() {
+    var v;
+
+    beforeEach(function() {
+      v = view.get('textFieldView').create();
+    });
+
+    describe('#disabled', function() {
+      it('should be inverted to isEnabled', function () {
+        v.set('isEnabled', false);
+        expect(v.get('disabled')).to.equal(true);
+        v.set('isEnabled', true);
+        expect(v.get('disabled')).to.equal(false);
+      });
+    });
+
+  });
+
+});
+
+describe('App.SshKeyFileUploader', function() {
+
+  beforeEach(function() {
+    view = App.SshKeyFileUploader.create();
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/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 4f5d473..e5fb996 100644
--- a/ambari-web/test/views/wizard/step3_view_test.js
+++ b/ambari-web/test/views/wizard/step3_view_test.js
@@ -443,6 +443,52 @@ describe('App.WizardStep3View', function () {
     });
   });
 
+  describe('#didInsertElement', function() {
+    beforeEach(function() {
+      v = App.WizardStep3View.create({
+        controller: Em.Object.create({
+          loadStep: Em.K
+        })
+      });
+      sinon.spy(v.get('controller'), 'loadStep');
+    });
+    afterEach(function() {
+      v.get('controller').loadStep.restore();
+    });
+    it('should call loadStep', function() {
+      v.didInsertElement();
+      expect(v.get('controller').loadStep.calledOnce).to.equal(true);
+    });
+  });
+
+  describe('#categoryObject', function() {
+    var o;
+    beforeEach(function() {
+      v = App.WizardStep3View.create();
+      o = v.get('categoryObject').create();
+    });
+
+    describe('#label', function() {
+      it('should use value and hostCount', function() {
+        o.setProperties({
+          value: 'abc',
+          hostsCount: 3
+        });
+        expect(o.get('label')).to.equal('abc (3)');
+      });
+    });
+
+    describe('#itemClass', function() {
+      it('should depends on isActive', function() {
+        o.set('isActive', true);
+        expect(o.get('itemClass')).to.equal('active');
+        o.set('isActive', false);
+        expect(o.get('itemClass')).to.equal('');
+      });
+    });
+
+  });
+
 });
 
 var wView;

http://git-wip-us.apache.org/repos/asf/ambari/blob/e702b317/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 973f188..d2e94ce 100644
--- a/ambari-web/test/views/wizard/step5_view_test.js
+++ b/ambari-web/test/views/wizard/step5_view_test.js
@@ -23,11 +23,13 @@ require('views/wizard/step5_view');
 var view;
 
 describe('App.WizardStep5View', function() {
+
   beforeEach(function() {
     view = App.WizardStep5View.create({
       controller: App.WizardStep5Controller.create({})
     });
   });
+
   describe('#didInsertElement', function() {
     it('should call controller.loadStep', function() {
       sinon.stub(view.get('controller'), 'loadStep', Em.K);
@@ -36,9 +38,11 @@ describe('App.WizardStep5View', function() {
       view.get('controller').loadStep.restore();
     });
   });
+
 });
 
 describe('App.SelectHostView', function() {
+
   beforeEach(function() {
     view = App.SelectHostView.create({
       controller: App.WizardStep5Controller.create({})
@@ -252,9 +256,67 @@ describe('App.SelectHostView', function() {
     });
   });
 
+  describe('#click', function() {
+    beforeEach(function() {
+      sinon.stub(lazyloading, 'run', Em.K);
+    });
+    afterEach(function() {
+      lazyloading.run.restore();
+    });
+    Em.A([
+        {
+          isLoaded: true,
+          isLazyLoading: true,
+          e: false
+        },
+        {
+          isLoaded: true,
+          isLazyLoading: false,
+          e: false
+        },
+        {
+          isLoaded: false,
+          isLazyLoading: true,
+          e: true
+        },
+        {
+          isLoaded: false,
+          isLazyLoading: false,
+          e: false
+        }
+      ]).forEach(function(test) {
+      it('isLoaded = ' + test.isLoaded.toString() + ', isLazyLoading = ' + test.isLazyLoading.toString(),
function() {
+        view.reopen({
+          isLazyLoading: test.isLazyLoading,
+          isLoaded: test.isLoaded
+        });
+        view.click();
+        if(test.e) {
+          expect(lazyloading.run.calledOnce).to.equal(true);
+        }
+        else {
+          expect(lazyloading.run.called).to.equal(false);
+        }
+      });
+    });
+    it('check lazyLoading parameters', function() {
+      view.reopen({
+        isLoaded: false,
+        isLazyLoading: true,
+        content: [{host_name: 'host1'}, {host_name: 'host2'}]
+      });
+      var availableHosts = d3.range(1, 100).map(function(i) {return {host_name: 'host' +
i.toString()};});
+      sinon.stub(view, 'getAvailableHosts', function() {return availableHosts;});
+      view.click();
+      expect(lazyloading.run.args[0][0].source.length).to.equal(97); // 99-2
+      view.getAvailableHosts.restore();
+    });
+  });
+
 });
 
 describe('App.RemoveControlView', function() {
+
   beforeEach(function() {
     view = App.RemoveControlView.create({
       controller: App.WizardStep5Controller.create({})
@@ -275,9 +337,11 @@ describe('App.RemoveControlView', function() {
       expect(view.get('controller').removeComponent.calledWith('c1', 1)).to.equal(true);
     });
   });
+
 });
 
 describe('App.AddControlView', function() {
+
   beforeEach(function() {
     view = App.AddControlView.create({
       controller: App.WizardStep5Controller.create({})
@@ -285,16 +349,21 @@ describe('App.AddControlView', function() {
   });
 
   describe('#click', function() {
+
     beforeEach(function() {
       sinon.stub(view.get('controller'), 'addComponent', Em.K);
     });
+
     afterEach(function() {
       view.get('controller').addComponent.restore();
     });
+
     it('should call addComponent', function() {
       view.set('componentName', 'c1');
       view.click();
       expect(view.get('controller').addComponent.calledWith('c1')).to.equal(true);
     });
+
   });
+
 });
\ No newline at end of file


Mime
View raw message