Author: yusaku
Date: Wed May 29 01:59:51 2013
New Revision: 1487194

URL: http://svn.apache.org/r1487194
Log:
AMBARI-2206. Add unit tests for wizard steps 2, 5, and 6. (yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js
    incubator/ambari/trunk/ambari-web/app/controllers/wizard/step6_controller.js
    incubator/ambari/trunk/ambari-web/test/installer/step2_test.js
    incubator/ambari/trunk/ambari-web/test/installer/step5_test.js
    incubator/ambari/trunk/ambari-web/test/installer/step6_test.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1487194&r1=1487193&r2=1487194&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Wed May 29 01:59:51 2013
@@ -309,6 +309,8 @@ Trunk (unreleased changes):
 
  IMPROVEMENTS
 
+ AMBARI-2206. Add unit tests for wizard steps 2, 5, and 6. (yusaku)
+
  AMBARI-2194. Hadoop2 Installer: MapReduce2 shows only advanced section. 
  (srimanth)
 

Modified: 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js?rev=1487194&r1=1487193&r2=1487194&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js 
(original)
+++ 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js 
Wed May 29 01:59:51 2013
@@ -356,15 +356,6 @@ App.WizardStep3Controller = Em.Controlle
     }
   },
 
-  /*
-   stopBootstrap: function () {
-   console.log('stopBootstrap() called');
-   Ember.run.later(this, function () {
-   this.startRegistration();
-   }, 1000);
-   },
-   */
-
   startRegistration: function () {
     if (this.get('registrationStartedAt') == null) {
       this.set('registrationStartedAt', new Date().getTime());

Modified: 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step6_controller.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step6_controller.js?rev=1487194&r1=1487193&r2=1487194&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step6_controller.js 
(original)
+++ 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step6_controller.js 
Wed May 29 01:59:51 2013
@@ -146,8 +146,8 @@ App.WizardStep6Controller = Em.Controlle
    * @return {*}
    */
   isServiceSelected: function (name) {
-    return this.get('content.services').findProperty('serviceName', name) &&
-      this.get('content.services').findProperty('serviceName', 
name).get('isSelected');
+    return !!(this.get('content.services').findProperty('serviceName', name) &&
+      this.get('content.services').findProperty('serviceName', 
name).get('isSelected'));
   },
 
   /**

Modified: incubator/ambari/trunk/ambari-web/test/installer/step2_test.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step2_test.js?rev=1487194&r1=1487193&r2=1487194&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step2_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/installer/step2_test.js Wed May 29 
01:59:51 2013
@@ -20,6 +20,7 @@ var App = require('app');
 var Ember = require('ember');
 require('controllers/wizard/step2_controller');
 require('models/host');
+require('models/host_component');
 require('messages');
 
 describe('App.WizardStep2Controller', function () {

Modified: incubator/ambari/trunk/ambari-web/test/installer/step5_test.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step5_test.js?rev=1487194&r1=1487193&r2=1487194&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step5_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/installer/step5_test.js Wed May 29 
01:59:51 2013
@@ -19,166 +19,88 @@
 var Ember = require('ember');
 var App = require('app');
 require('controllers/wizard/step5_controller');
+var components = require('data/service_components');
 
-/*
-describe('App.InstallerStep5Controller', function () {
-  var controller = App.InstallerStep5Controller.create();
-  controller.get("selectedServices").pushObject({service_name: 'ZOOKEEPER'});
-  var cpu = 2, memory = 4;
-  var HOST = ['host1', 'host2', 'host3', 'host4', 'host5'];
-  var hosts = [];
-  HOST.forEach(function (_host) {
-    controller.get('hosts').pushObject(Ember.Object.create({
-      host_name: _host,
-      cpu: cpu,
-      memory: memory
-    }));
-  });
-
-  var componentObj = Ember.Object.create({
-    component_name: 'ZooKeeper',
-    selectedHost: 'host2', // call the method that plays selectNode algorithm 
or fetches from server
-    availableHosts: []
-  });
-  componentObj.set('availableHosts', controller.get('hosts').slice(0));
-  componentObj.set('zId', 1);
-  componentObj.set("showAddControl", true);
-  componentObj.set("showRemoveControl", false);
-  controller.get("selectedServicesMasters").pushObject(componentObj);
-
-
-  describe('#getAvailableHosts()', function () {
-    it('should generate available hosts for a new zookeeper service', function 
() {
-      var hostsForNewZookeepers = controller.getAvailableHosts("ZooKeeper"),
-        ok = true, i = 0, masters = null;
-
-      //test that the hosts found, do not have Zookeeper master assigned to 
them
-      for (i = 0; i < hostsForNewZookeepers.get("length"); i++) {
-        masters = 
controller.get("selectedServicesMasters").filterProperty(hostsForNewZookeepers[i].get("host_name"));
-        if (masters.findProperty("component_name", "ZooKeeper")) {
-          ok = false;
-          break;
-        }
-      }
-
-      expect(ok).to.equal(true);
-    })
 
-    it('should return all hosts for services other than ZooKeeper', function 
() {
-      var hostsForNewZookeepers = controller.getAvailableHosts("");
+describe('App.WizardStep5Controller', function () {
+  var cpu = 2, memory = 4;
 
-      
expect(hostsForNewZookeepers.get("length")).to.equal(controller.get("hosts.length"));
-    })
-  })
+  var methods = ['getKerberosServer', 'getNameNode', 'getSNameNode', 
'getJobTracker', 'getResourceManager', 'getHistoryServer', 'getHBaseMaster', 
'getOozieServer', 'getHiveServer', 'getHiveMetastore', 'getWebHCatServer'];
 
-  describe('#assignHostToMaster()', function () {
-    it('should assign the selected host to the non-ZooKeeper master service', 
function () {
-      //test non-zookeeper master
-      var SERVICE_MASTER = "NameNode",
-        HOST = "host4", ZID, status;
-      var nonZookeeperObj = Ember.Object.create({
-        component_name: SERVICE_MASTER,
-        selectedHost: HOST, // call the method that plays selectNode algorithm 
or fetches from server
-        availableHosts: []
+  var test_config = [
+    {
+      title: '1 host',
+      hosts: ['host0'],
+      equals: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+    },
+    {
+      title: '2 hosts',
+      hosts: ['host0', 'host1'],
+      equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
+    },
+    {
+      title: '3 hosts',
+      hosts: ['host0', 'host1', 'host2'],
+      equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
+    },
+    {
+      title: '5 hosts',
+      hosts: ['host0', 'host1', 'host2', 'host3', 'host4'],
+      equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
+    },
+    {
+      title: '6 hosts',
+      hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host6'],
+      equals: [3, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
+    },
+    {
+      title: '10 hosts',
+      hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 
'host7', 'host8', 'host9'],
+      equals: [3, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
+    },
+    {
+      title: '31 hosts',
+      hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 
'host7', 'host8', 'host9', 'host0', 'host1', 'host2', 'host3', 'host4', 
'host5', 'host6', 'host7', 'host8', 'host9', 'host0', 'host1', 'host2', 
'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0'],
+      equals: [5, 0, 1, 2, 2, 2, 3, 3, 4, 4, 4]
+    }
+  ];
+
+  test_config.forEach(function(test) {
+    describe(test.title, function() {
+      var controller = App.WizardStep5Controller.create();
+      controller.clearStep();
+
+      test.hosts.forEach(function(_host) {
+        controller.get('hosts').pushObject(Em.Object.create({
+          host_name: _host,
+          cpu: cpu,
+          memory: memory
+        }));
       });
-      controller.get("selectedServicesMasters").pushObject(nonZookeeperObj);
-      controller.assignHostToMaster(SERVICE_MASTER, HOST);
-      
expect(controller.get("selectedServicesMasters").findProperty("component_name", 
SERVICE_MASTER).get("selectedHost")).to.equal(HOST);
-    })
-
-    it('should assign the selected host to the ZooKeeper master service', 
function () {
-      //test non-zookeeper master
-      var SERVICE_MASTER = "ZooKeeper",
-        HOST = "host4", ZID = 2;
-
-      //test zookeeper master assignment with
-      if (controller.addZookeepers()) {
-        controller.assignHostToMaster(SERVICE_MASTER, HOST, ZID);
-        
expect(controller.get("selectedServicesMasters").filterProperty("component_name",
 "ZooKeeper").findProperty("zId", ZID).get("selectedHost")).to.equal(HOST);
-      }
-    })
-  })
-
-  describe('#addZookeepers()', function () {
 
-    it('should add a new ZooKeeper', function () {
-      var newLength = 0;
-      if 
(controller.get("selectedServices").mapProperty("service_name").contains("ZOOKEEPER")
-        && 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper").get("length") < controller.get("hosts.length")) {
-        newLength = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper").get("length");
-        controller.addZookeepers();
-        
expect(controller.get("selectedServicesMasters").filterProperty("component_name",
 "ZooKeeper").get("length")).to.equal(newLength + 1);
-      }
-    })
-
-    it('should add ZooKeepers up to the number of hosts', function () {
-
-      var currentZooKeepers = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper").length,
-        success = true;
-
-      //add ZooKeepers as long as possible
-      if (currentZooKeepers) {
-
-        while (success) {
-          success = controller.addZookeepers();
-        }
-        var services = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper");
-        var length = services.length;
-        
expect(controller.get("selectedServicesMasters").filterProperty("component_name",
 "ZooKeeper").length).to.equal(controller.get("hosts.length"));
-      }
-    })
-  })
-
-  describe('#removeZookeepers()', function () {
-    it('should remove a ZooKeeper', function () {
-      if 
(controller.get("selectedServices").mapProperty("service_name").contains("ZOOKEEPER"))
 {
-        if (controller.addZookeepers()) {
-          newLength = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper").get("length");
-          controller.removeZookeepers(2);
-          
expect(controller.get("selectedServicesMasters").filterProperty("component_name",
 "ZooKeeper").get("length")).to.equal(newLength - 1);
-        }
-      }
-    })
+      methods.forEach(function(method, index) {
+        it('#' + method + '()', function() {
+          
expect(controller[method](test.hosts.length).host_name).to.equal(test.hosts[test.equals[index]]);
+        });
+      });
 
-    it('should fail to remove a ZooKeeper if there is only 1', function () {
-      var currentZooKeepers = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper").length,
-        success = true;
-      //remove ZooKeepers as long as possible
-
-      if (currentZooKeepers) {
-        while (success) {
-          success = 
controller.removeZookeepers(controller.get("selectedServicesMasters").filterProperty("component_name",
 "ZooKeeper").get("lastObject.zId"));
-        }
-        
expect(controller.get("selectedServicesMasters").filterProperty("component_name",
 "ZooKeeper").get("length")).to.equal(1);
-      }
-    })
+    });
 
-  })
+  });
 
-  describe('#rebalanceZookeeperHosts()', function () {
 
-    it('should rebalance hosts for ZooKeeper', function () {
-      //assign a host to a zookeeper and then rebalance the available hosts 
for the other zookeepers
-      var zookeepers = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper"),
-        aZookeeper = null, aHost = null, i = 0, ok = true;
-
-      if (zookeepers.get("length") > 1) {
-        aZookeeper = 
controller.get("selectedServicesMasters").filterProperty("component_name", 
"ZooKeeper").findProperty("zId", 1);
-        aHost = aZookeeper.get("availableHosts")[0];
-        aZookeeper.set("selectedHost", aHost.get("host_name"));
-
-        controller.rebalanceZookeeperHosts();
-
-        for (i = 0; i < zookeepers.get("length"); i++) {
-          if 
(zookeepers[i].get("availableHosts").mapProperty("host_name").contains(aHost)) {
-            ok = false;
-            break;
-          }
-        }
+  var controller = App.WizardStep5Controller.create();
+  controller.set('content', {});
 
-        expect(ok).to.equal(true);
-      }
+  describe('#isReassignWizard', function() {
+    it('true if content.controllerName is reassignMasterController', 
function() {
+      controller.set('content.controllerName', 'reassignMasterController');
+      expect(controller.get('isReassignWizard')).to.equal(true);
+    })
+    it('false if content.controllerName is not reassignMasterController', 
function() {
+      controller.set('content.controllerName', 'mainController');
+      expect(controller.get('isReassignWizard')).to.equal(false);
     })
-  })
+  });
 
-})*/
+});

Modified: incubator/ambari/trunk/ambari-web/test/installer/step6_test.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step6_test.js?rev=1487194&r1=1487193&r2=1487194&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step6_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/installer/step6_test.js Wed May 29 
01:59:51 2013
@@ -20,135 +20,183 @@ var Ember = require('ember');
 var App = require('app');
 require('controllers/wizard/step6_controller');
 
-/*
-describe('App.InstallerStep6Controller', function () {
+describe('App.WizardStep6Controller', function () {
 
-  var HOSTS = [ 'host1', 'host2', 'host3', 'host4' ];
-  //App.InstallerStep6Controller.set.rawHosts = HOSTS;
-  var controller = App.InstallerStep6Controller.create();
-  controller.set('showHbase', false);
-  HOSTS.forEach(function (_hostName) {
-    controller.get('hosts').pushObject(Ember.Object.create({
-      hostname: _hostName,
-      isDataNode: true,
-      isTaskTracker: true,
-      isRegionServer: true
-    }));
-  });
-
-
-
-describe('#selectAllDataNodes()', function () {
-  controller.get('hosts').setEach('isDataNode', false);
-
-  it('should set isDataNode to true on all hosts', function () {
-    controller.selectAllDataNodes();
-    expect(controller.get('hosts').everyProperty('isDataNode', 
true)).to.equal(true);
-  })
-})
-
-describe('#selectAllTaskTrackers()', function () {
-  it('should set isTaskTracker to true on all hosts', function () {
-    controller.selectAllTaskTrackers();
-    expect(controller.get('hosts').everyProperty('isTaskTracker', 
true)).to.equal(true);
-  })
-})
-
-describe('#selectAllRegionServers()', function () {
-  it('should set isRegionServer to true on all hosts', function () {
-    controller.selectAllRegionServers();
-    expect(controller.get('hosts').everyProperty('isRegionServer', 
true)).to.equal(true);
-  })
-})
-
-describe('#isAllDataNodes()', function () {
-
-  beforeEach(function () {
-    controller.get('hosts').setEach('isDataNode', true);
-  })
-
-  it('should return true if isDataNode is true for all services', function () {
-    expect(controller.get('isAllDataNodes')).to.equal(true);
-  })
-
-  it('should return false if isDataNode is false for one host', function () {
-    controller.get('hosts')[0].set('isDataNode', false);
-    expect(controller.get('isAllDataNodes')).to.equal(false);
-  })
-})
-
-describe('#isAllTaskTrackers()', function () {
-
-  beforeEach(function () {
-    controller.get('hosts').setEach('isTaskTracker', true);
-  })
-
-  it('should return true if isTaskTracker is true for all hosts', function () {
-    expect(controller.get('isAllTaskTrackers')).to.equal(true);
-  })
-
-  it('should return false if isTaskTracker is false for one host', function () 
{
-    controller.get('hosts')[0].set('isTaskTracker', false);
-    expect(controller.get('isAllTaskTrackers')).to.equal(false);
-  })
-
-})
-
-describe('#isAllRegionServers()', function () {
-
-  beforeEach(function () {
-    controller.get('hosts').setEach('isRegionServer', true);
-  });
-
-  it('should return true if isRegionServer is true for all hosts', function () 
{
-    expect(controller.get('isAllRegionServers')).to.equal(true);
-  })
-
-  it('should return false if isRegionServer is false for one host', function 
() {
-    controller.get('hosts')[0].set('isRegionServer', false);
-    expect(controller.get('isAllRegionServers')).to.equal(false);
-  })
-
-})
-
-describe('#validate()', function () {
-
-  beforeEach(function () {
-    controller.get('hosts').setEach('isDataNode', true);
-    controller.get('hosts').setEach('isTaskTracker', true);
-    controller.get('hosts').setEach('isRegionServer', true);
-  });
-
-  it('should return false if isDataNode is false for all hosts', function () {
-    controller.get('hosts').setEach('isDataNode', false);
-    expect(controller.validate()).to.equal(false);
-  })
-
-  it('should return false if isTaskTracker is false for all hosts', function 
() {
-    controller.get('hosts').setEach('isTaskTracker', false);
-    expect(controller.validate()).to.equal(false);
-  })
-
-  it('should return false if isRegionServer is false for all hosts', function 
() {
-    controller.get('hosts').setEach('isRegionServer', false);
-    expect(controller.validate()).to.equal(false);
-  })
-
-  it('should return true if isDataNode, isTaskTracker, and isRegionServer is 
true for all hosts', function () {
-    expect(controller.validate()).to.equal(true);
-  })
-
-  it('should return true if isDataNode, isTaskTracker, and isRegionServer is 
true for only one host', function () {
-    controller.get('hosts').setEach('isDataNode', false);
-    controller.get('hosts').setEach('isTaskTracker', false);
-    controller.get('hosts').setEach('isRegionServer', false);
-    var host = controller.get('hosts')[0];
-    host.set('isDataNode', true);
-    host.set('isTaskTracker', true);
-    host.set('isRegionServer', true);
-    expect(controller.validate()).to.equal(true);
-  })
+  var controller = App.WizardStep6Controller.create();
 
-})
+  controller.set('content', {
+    hosts: {},
+    masterComponentHosts: {},
+    services: [
+      Em.Object.create({
+        serviceName: 'MAPREDUCE',
+        isSelected: true
+      }),
+      Em.Object.create({
+        serviceName: 'YARN',
+        isSelected: true
+      }),
+      Em.Object.create({
+        serviceName: 'HBASE',
+        isSelected: true
+      })
+    ]
+  });
+
+  var HOSTS = [ 'host0', 'host1', 'host2', 'host3' ];
+
+  var h = {};
+  var m = [];
+  HOSTS.forEach(function (hostName) {
+    var obj = Em.Object.create({
+      name: hostName,
+      hostName: hostName,
+      bootStatus: 'REGISTERED'
+    });
+    h[hostName] = obj;
+    m.push(obj);
+  });
+
+  controller.set('content.hosts', h);
+  controller.set('content.masterComponentHosts', m);
+  controller.set('isMasters', false);
+
+
+  describe('#loadStep', function() {
+    controller.loadStep();
+    it('Hosts are loaded', function() {
+      expect(controller.get('hosts').length).to.equal(HOSTS.length);
+    });
+
+    it('Headers are loaded', function() {
+      expect(controller.get('headers').length).not.to.equal(0);
+    });
+  });
+
+  describe('#isAddHostWizard', function() {
+    it('true if content.controllerName is addHostController', function() {
+      controller.set('content.controllerName', 'addHostController');
+      expect(controller.get('isAddHostWizard')).to.equal(true);
+    });
+    it('false if content.controllerName is not addHostController', function() {
+      controller.set('content.controllerName', 'mainController');
+      expect(controller.get('isAddHostWizard')).to.equal(false);
+    });
+  });
+
+  describe('#isInstallerWizard', function() {
+    it('true if content.controllerName is addHostController', function() {
+      controller.set('content.controllerName', 'installerController');
+      expect(controller.get('isInstallerWizard')).to.equal(true);
+    });
+    it('false if content.controllerName is not addHostController', function() {
+      controller.set('content.controllerName', 'mainController');
+      expect(controller.get('isInstallerWizard')).to.equal(false);
+    });
+  });
+
+  describe('#hasMasterComponents', function() {
+    HOSTS.forEach(function(host) {
+      it('Host ' + host + ' is master', function() {
+        expect(controller.hasMasterComponents(host)).to.equal(true);
+      });
+    });
+    var notMasterHost = 'NotMasterHost';
+    it('Host ' + notMasterHost + ' is not master', function() {
+      expect(controller.hasMasterComponents(notMasterHost)).to.equal(false);
+    });
+  });
+
+  describe('#setAllNodes', function() {
+
+    var test_config = [
+      {
+        title: 'DataNode',
+        state: false
+      },
+      {
+        title: 'DataNode',
+        state: true
+      },
+      {
+        title: 'TaskTracker',
+        state: false
+      },
+      {
+        title: 'TaskTracker',
+        state: true
+      }
+    ];
+
+    test_config.forEach(function(test) {
+      it((test.state?'Select':'Deselect') + ' all ' + test.title, function() {
+        controller.setAllNodes(test.title, test.state);
+        var hosts = controller.get('hosts');
+        hosts.forEach(function(host) {
+          expect(host.get('checkboxes').findProperty('title', 
test.title).get('checked')).to.equal(test.state);
+        });
+      });
+    });
+
+
+  });
+
+  describe('#isServiceSelected', function() {
+    controller.get('content.services').forEach(function(service) {
+      it(service.serviceName + ' is selected', function() {
+        
expect(controller.isServiceSelected(service.serviceName)).to.equal(true);
+      });
+    });
+    var unselectedService = 'FAKESERVICE';
+    it(unselectedService + ' is not selected', function() {
+      expect(controller.isServiceSelected(unselectedService)).to.equal(false);
+    });
+  });
+
+  describe('#validateEachComponent', function() {
+    it('Nothing checked', function() {
+      controller.get('hosts').forEach(function(host) {
+        host.get('checkboxes').setEach('checked', false);
+      });
+      expect(controller.validateEachComponent('')).to.equal(false);
+    });
+    it('One slave is not selected for no one host', function() {
+      controller.get('hosts').forEach(function(host) {
+        host.get('checkboxes').forEach(function(checkbox, index) {
+          checkbox.set('checked', index === 0);
+        });
+      });
+      expect(controller.validateEachComponent('')).to.equal(false);
+    });
+    it('All checked', function() {
+      controller.get('hosts').forEach(function(host) {
+        host.get('checkboxes').forEach(function(checkbox) {
+          checkbox.set('checked', true);
+        });
+      });
+      expect(controller.validateEachComponent('')).to.equal(true);
+    });
+  });
+
+  describe('#validateEachHost', function() {
+    it('Nothing checked', function() {
+      controller.get('hosts').forEach(function(host) {
+        host.get('checkboxes').setEach('checked', false);
+      });
+      expect(controller.validateEachHost('')).to.equal(false);
+    });
+    it('One host doesn\'t have assigned slaves', function() {
+      controller.get('hosts').forEach(function(host, index) {
+        host.get('checkboxes').setEach('checked', index === 0);
+      });
+      expect(controller.validateEachHost('')).to.equal(false);
+    });
+    it('All checked', function() {
+      controller.get('hosts').forEach(function(host) {
+        host.get('checkboxes').setEach('checked', true);
+      });
+      expect(controller.validateEachHost('')).to.equal(true);
+    });
+  });
 
-})*/
+});


Reply via email to