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 2016/02/01 17:27:55 UTC
ambari git commit: AMBARI-14860. Remove assertions in loops in the
tests (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 3ab6a3a83 -> 31477a588
AMBARI-14860. Remove assertions in loops in the tests (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/31477a58
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/31477a58
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/31477a58
Branch: refs/heads/trunk
Commit: 31477a588a1af89f8a156af4d9efb04b61508fe0
Parents: 3ab6a3a
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Feb 1 15:40:09 2016 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Feb 1 18:17:44 2016 +0200
----------------------------------------------------------------------
.../global/cluster_controller_test.js | 4 +-
.../progress_controller_test.js | 4 +-
.../admin/kerberos/step4_controller_test.js | 7 +-
...anage_alert_notifications_controller_test.js | 85 +++++++++++---------
.../main/host/add_controller_test.js | 2 +
.../test/controllers/wizard/step3_test.js | 43 +++++-----
.../test/controllers/wizard/step4_test.js | 19 ++++-
.../test/controllers/wizard/step5_test.js | 7 +-
.../test/controllers/wizard/step6_test.js | 6 +-
.../test/controllers/wizard/step7_test.js | 13 +--
.../test/controllers/wizard/step8_test.js | 19 +++--
.../test/controllers/wizard/step9_test.js | 23 +++---
ambari-web/test/controllers/wizard_test.js | 8 +-
ambari-web/test/mappers/service_mapper_test.js | 8 +-
.../common/configs/toggle_isrequired_test.js | 12 +--
.../kdc_credentials_controller_mixin_test.js | 29 ++++---
.../test/mixins/common/serverValidator_test.js | 14 +++-
ambari-web/test/models/cluster_states_test.js | 20 +++--
.../objects/service_config_property_test.js | 38 ++++-----
ambari-web/test/router_test.js | 84 +++++++++----------
ambari-web/test/utils/ajax/ajax_queue_test.js | 2 +-
ambari-web/test/utils/config_test.js | 32 ++++----
ambari-web/test/utils/date/timezone_test.js | 24 +++---
ambari-web/test/utils/helper_test.js | 6 +-
.../test/views/common/chart/linear_time_test.js | 16 ++--
.../common/configs/service_config_view_test.js | 18 +++--
.../modal_popups/cluster_check_popup_test.js | 12 ++-
.../manage_alert_notifications_view_test.js | 17 ++--
ambari-web/test/views/wizard/step3_view_test.js | 31 ++++---
ambari-web/test/views/wizard/step9_view_test.js | 71 ++++++++++------
30 files changed, 386 insertions(+), 288 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index a791b19..d2c6876 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -190,8 +190,8 @@ describe('App.clusterController', function () {
controller.set('clusterName', 'tdk');
var tests = ['test1', 'test2', 'test3'];
- it('testMode = false', function () {
- tests.forEach(function (test) {
+ tests.forEach(function (test) {
+ it(test, function () {
expect(controller.getUrl(test, test)).to.equal(App.apiPrefix + '/clusters/' + controller.get('clusterName') + test);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
index f002754..0f1b18d 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
@@ -132,8 +132,8 @@ describe('App.HighAvailabilityProgressPageController', function () {
Date.prototype.getTime.restore();
});
- it("reconfigures configs after HA", function() {
- tests.forEach(function(t) {
+ tests.forEach(function(t, index) {
+ it("reconfigures configs after HA #" + (index + 1), function() {
controller.set('content', t.content);
expect(controller.reconfigureSites(t.siteNames, t.data, t.note)).to.eql(t.result);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 6c4a1fb..fa78916 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -49,9 +49,10 @@ describe('App.KerberosWizardStep4Controller', function() {
describe('#createServiceConfig', function() {
var controller = App.KerberosWizardStep4Controller.create({});
it('should create instance of App.ServiceConfig', function() {
- controller.createServiceConfig([], []).forEach(function(item){
- expect(item).be.instanceof(App.ServiceConfig);
- });
+ var configs = controller.createServiceConfig([], []);
+ expect(configs).to.have.property('length').equal(2);
+ expect(configs[0]).to.be.instanceof(App.ServiceConfig);
+ expect(configs[1]).to.be.instanceof(App.ServiceConfig);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index 84caec6..19d0c1b 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -102,45 +102,48 @@ describe('App.ManageAlertNotificationsController', function () {
describe('#addAlertNotification()', function () {
+ var inputFields = Em.Object.create({
+ a: {
+ value: '',
+ defaultValue: 'a'
+ },
+ b: {
+ value: '',
+ defaultValue: 'b'
+ },
+ c: {
+ value: '',
+ defaultValue: 'c'
+ },
+ severityFilter: {
+ value: [],
+ defaultValue: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']
+ },
+ global: {
+ value: false
+ },
+ allGroups: Em.Object.create({
+ value: 'custom'
+ })
+ });
+
beforeEach(function () {
sinon.stub(controller, 'showCreateEditPopup');
+ controller.set('inputFields', inputFields);
+ controller.addAlertNotification();
});
afterEach(function () {
controller.showCreateEditPopup.restore();
});
- it("should set value for inputFields and call showCreateEditPopup", function () {
-
- controller.set('inputFields', Em.Object.create({
- a: {
- value: '',
- defaultValue: 'a'
- },
- b: {
- value: '',
- defaultValue: 'b'
- },
- c: {
- value: '',
- defaultValue: 'c'
- },
- severityFilter: {
- value: [],
- defaultValue: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']
- },
- global: {
- value: false
- },
- allGroups: Em.Object.create({
- value: 'custom'
- })
- }));
- controller.addAlertNotification();
-
- Em.keys(controller.get('inputFields')).forEach(function (key) {
- expect(controller.get('inputFields.' + key + '.value')).to.eql(controller.get('inputFields.' + key + '.defaultValue'));
+ Object.keys(inputFields).forEach(function (key) {
+ it(key, function () {
+ expect(controller.get('inputFields.' + key + '.value')).to.be.eql(controller.get('inputFields.' + key + '.defaultValue'));
});
+ });
+
+ it("should call showCreateEditPopup", function () {
expect(controller.showCreateEditPopup.calledOnce).to.be.true;
});
@@ -664,16 +667,26 @@ describe('App.ManageAlertNotificationsController', function () {
});
cases.forEach(function (item) {
- it(item.method, function () {
- item.errors.forEach(function (errorName) {
- view.set(errorName, true);
+ describe(item.method, function () {
+
+ beforeEach(function () {
+ item.errors.forEach(function (errorName) {
+ view.set(errorName, true);
+ });
+ view.set('controller.inputFields.method.value', item.method);
});
- view.set('controller.inputFields.method.value', item.method);
+
item.errors.forEach(function (errorName) {
- expect(view.get(errorName)).to.be.false;
+ it(errorName + ' is false', function () {
+ expect(view.get(errorName)).to.be.false;
+ });
+
});
validators.forEach(function (validatorName) {
- expect(view.get(validatorName).calledOnce).to.equal(item.validators.contains(validatorName));
+ var called = item.validators.contains(validatorName);
+ it(validatorName + ' ' + (called ? '' : 'not') + ' called', function () {
+ expect(view.get(validatorName).calledOnce).to.equal(called);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/host/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js
index ed8e78b..1c78da4 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -1172,6 +1172,7 @@ describe('App.AddHostController', function () {
});
});
+ /*eslint-disable mocha-cleanup/no-assertions-in-loop*/
describe("#loadAllPriorSteps()", function () {
var stepsSet = {
'1': [
@@ -1313,6 +1314,7 @@ describe('App.AddHostController', function () {
});
}, this);
});
+ /*eslint-enable mocha-cleanup/no-assertions-in-loop*/
describe("#clearAllSteps()", function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index ee38304..438554b 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -1630,21 +1630,24 @@ describe('App.WizardStep3Controller', function () {
c.parseHostCheckWarnings({tasks: test.tasks});
});
- it('warnings', function () {
- c.get('warnings').forEach(function (w, i) {
- Em.keys(test.e.warnings[i]).forEach(function (k) {
- expect(w[k]).to.eql(test.e.warnings[i][k]);
+ it('warnings count is valid', function () {
+ expect(c.get('warnings.length')).to.be.equal(test.e.warnings.length);
+ });
+
+ test.e.warnings.forEach(function (warning, index) {
+ Object.keys(warning).forEach(function (warningKey) {
+ it('warning #' + (index + 1) + ' key: ' + warningKey, function () {
+ expect(c.get('warnings')[index][warningKey]).to.be.eql(warning[warningKey]);
});
});
});
- it('warningsByHost', function () {
- for (var i in test.e.warningsByHost) {
- if (test.e.warningsByHost.hasOwnProperty(i)) {
- expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
- }
- }
+ Object.keys(test.e.warningsByHost).forEach(function (warningByHostKey, index) {
+ it ('warningsByHost #' + (index + 1), function () {
+ expect(c.get('warningsByHost')[index].warnings.length).to.equal(test.e.warningsByHost[warningByHostKey]);
+ });
});
+
});
});
});
@@ -2095,21 +2098,21 @@ describe('App.WizardStep3Controller', function () {
beforeEach(function () {
c.parseWarnings({items: test.items});
});
- it('warnings', function () {
- c.get('warnings').forEach(function (w, i) {
- Em.keys(test.e.warnings[i]).forEach(function (k) {
- expect(w[k]).to.eql(test.e.warnings[i][k]);
+
+ test.e.warnings.forEach(function (warning, index) {
+ Object.keys(warning).forEach(function (warningKey) {
+ it('warning #' + (index + 1) + ' key: ' + warningKey, function () {
+ expect(c.get('warnings')[index][warningKey]).to.be.eql(warning[warningKey]);
});
});
});
- it('warningsByHost', function () {
- for (var i in test.e.warningsByHost) {
- if (test.e.warningsByHost.hasOwnProperty(i)) {
- expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
- }
- }
+ Object.keys(test.e.warningsByHost).forEach(function (warningByHostKey, index) {
+ it ('warningsByHost #' + (index + 1), function () {
+ expect(c.get('warningsByHost')[index].warnings.length).to.equal(test.e.warningsByHost[warningByHostKey]);
+ });
});
+
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step4_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step4_test.js b/ambari-web/test/controllers/wizard/step4_test.js
index 611aa27..80667c9 100644
--- a/ambari-web/test/controllers/wizard/step4_test.js
+++ b/ambari-web/test/controllers/wizard/step4_test.js
@@ -225,11 +225,22 @@ describe('App.WizardStep4Controller', function () {
tests.forEach(function(test) {
var message = 'Erorrs {0} thrown. errorStack property should contains ids: {1}'
.format(test.errorObjects.mapProperty('id').join(', '), test.expectedIds.join(', '));
- it(message, function() {
- test.errorObjects.forEach(function(errorObject) {
- expect(controller.addValidationError(errorObject)).to.equal(errorObject.shouldBeAdded);
+ describe(message, function() {
+
+ beforeEach(function () {
+ this.added = [];
+ test.errorObjects.forEach(function(errorObject) {
+ this.added.push(controller.addValidationError(errorObject));
+ }, this);
+ });
+
+ it('shouldBeAdded', function() {
+ expect(this.added).to.be.eql(test.errorObjects.mapProperty('shouldBeAdded'));
+ });
+
+ it('expectedIds', function() {
+ expect(controller.get('errorStack').mapProperty('id')).to.eql(test.expectedIds);
});
- expect(controller.get('errorStack').mapProperty('id')).to.eql(test.expectedIds);
});
})
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step5_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step5_test.js b/ambari-web/test/controllers/wizard/step5_test.js
index 2b3b023..a2bc687 100644
--- a/ambari-web/test/controllers/wizard/step5_test.js
+++ b/ambari-web/test/controllers/wizard/step5_test.js
@@ -709,11 +709,8 @@ describe('App.WizardStep5Controller', function () {
});
it('all needed hosts have valid data', function () {
- result.forEach(function (r, i) {
- expect(r.get('host_name')).to.equal(test.e[i].host_name);
- expect(r.get('masterServices.length')).to.equal(test.e[i].masterServices.length);
- expect(r.get('hostInfo')).to.be.an.object;
- });
+ expect(result.mapProperty('host_name')).to.be.eql(test.e.mapProperty('host_name'));
+ expect(result.mapProperty('masterServices.length')).to.be.eql(test.e.mapProperty('masterServices.length'));
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step6_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js
index 61cf879..56b9e96 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -1588,9 +1588,9 @@ describe('App.WizardStep6Controller', function () {
expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
});
- it('components are valid for each group', function () {
- controller.get('content.recommendationsHostGroups.blueprint.host_groups').forEach(function (group, index) {
- expect(group.components.mapProperty('name').sort()).to.eql(item.expected[index]);
+ item.expected.forEach(function (e, index) {
+ it('components are valid for group# ' + (index + 1), function () {
+ expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups')[index].components.mapProperty('name').sort()).to.be.eql(e);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 80e6ac5..d4dcb24 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1770,12 +1770,15 @@ describe('App.InstallerStep7Controller', function () {
expect(configs.length - oldConfigs.length).to.be.equal(6);
});
- it('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {
+ describe('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {
oldConfigs.forEach(function(property) {
- expect(configs.findProperty('id', property.name + '__hdfs-client').description).to.be.eql(property.description);
- expect(configs.findProperty('id', property.name + '__hdfs-client').displayName).to.be.eql(property.displayName);
- expect(configs.findProperty('id', property.name + '__hdfs-client').value).to.be.eql(property.value);
- expect(configs.findProperty('id', property.name + '__hdfs-client').recommendedValue).to.be.eql(property.recommendedValue);
+ var id = property.name + '__hdfs-client';
+ it(id, function () {
+ expect(configs.findProperty('id', id).description).to.be.equal(property.description);
+ expect(configs.findProperty('id', id).displayName).to.be.equal(property.displayName);
+ expect(configs.findProperty('id', id).value).to.be.equal(property.value);
+ expect(configs.findProperty('id', id).recommendedValue).to.be.equal(property.recommendedValue);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index b40b91c..298c9a8 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1171,13 +1171,22 @@ describe('App.WizardStep8Controller', function () {
describe('#deleteClusters', function() {
- it('should call App.ajax.send for each provided clusterName', function() {
+ describe('should call App.ajax.send for each provided clusterName', function() {
var clusterNames = ['h1', 'h2', 'h3'];
- installerStep8Controller.deleteClusters(clusterNames);
- var args = testHelpers.filterAjaxRequests('name', 'common.delete.cluster');
- expect(args).to.have.property('length').equal(clusterNames.length);
+ var args;
+ beforeEach(function () {
+ installerStep8Controller.deleteClusters(clusterNames);
+ args = testHelpers.filterAjaxRequests('name', 'common.delete.cluster');
+ });
+
+ it('args', function () {
+ expect(args).to.have.property('length').equal(clusterNames.length);
+ });
+
clusterNames.forEach(function(n, i) {
- expect(args[i][0].data).to.eql({name: n, isLast: i === clusterNames.length - 1});
+ it(n, function () {
+ expect(args[i][0].data).to.eql({name: n, isLast: i === clusterNames.length - 1});
+ });
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step9_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js
index 2eb8709..dd4f6cd 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -188,17 +188,24 @@ describe('App.InstallerStep9Controller', function () {
});
describe('#resetHostsForRetry', function () {
- it('All should have status "pending" and message "Waiting"', function () {
- var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
+ var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
+
+ beforeEach(function () {
c.reopen({content: {hosts: hosts}});
c.resetHostsForRetry();
- for (var name in hosts) {
- if (hosts.hasOwnProperty(name)) {
+ });
+
+ Object.keys(hosts).forEach(function (name) {
+ if (hosts.hasOwnProperty(name)) {
+ it(name + '.status', function () {
expect(c.get('content.hosts')[name].get('status', 'pending')).to.equal('pending');
+ });
+ it(name + '.message', function () {
expect(c.get('content.hosts')[name].get('message', 'Waiting')).to.equal('Waiting');
- }
+ });
}
});
+
});
describe('#setParseHostInfo', function () {
@@ -1353,10 +1360,8 @@ describe('App.InstallerStep9Controller', function () {
var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
- c.get('hosts').forEach(function (host) {
- expect(host.get('progress')).to.equal('100');
- expect(host.get('status')).to.equal('info');
- });
+ expect(c.get('hosts').everyProperty('progress', '100')).to.be.true;
+ expect(c.get('hosts').everyProperty('status', 'info')).to.be.true;
});
it('Next button should be disabled', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 06729dd..d9239200 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1187,9 +1187,7 @@ describe('App.WizardController', function () {
it('should not save admin_principal or admin_password to the localStorage', function () {
c.saveServiceConfigProperties(kerberosStepController);
var saved = c.get('content.serviceConfigProperties');
- saved.forEach(function(config) {
- expect(config.value).to.equal('');
- });
+ expect(saved.everyProperty('value', '')).to.be.true;
});
});
@@ -1475,8 +1473,8 @@ describe('App.WizardController', function () {
}
];
- it('should convert objects and arrays to pure JS objects and arrays', function () {
- testCases.forEach(function (testCase) {
+ testCases.forEach(function (testCase, index) {
+ it('should convert objects and arrays to pure JS objects and arrays (' + (index + 1) + ')', function () {
expect(c.toJSInstance(testCase.o)).to.eql(testCase.e);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mappers/service_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/service_mapper_test.js b/ambari-web/test/mappers/service_mapper_test.js
index 0634f19..4a8d49d 100644
--- a/ambari-web/test/mappers/service_mapper_test.js
+++ b/ambari-web/test/mappers/service_mapper_test.js
@@ -26,8 +26,7 @@ describe('App.serviceMetricsMapper', function () {
describe('#hbaseMapper', function() {
- it ('Round Average Load', function() {
- var tests = [
+ var tests = [
{
components: [
{
@@ -152,8 +151,9 @@ describe('App.serviceMetricsMapper', function () {
],
e: '1.20'
}
- ];
- tests.forEach(function(test) {
+ ];
+ tests.forEach(function(test) {
+ it('Round Average Load (' + test.e + ')', function () {
var result = App.serviceMetricsMapper.hbaseMapper(test);
expect(result.average_load).to.equal(test.e);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
index 49865db..4672ae6 100644
--- a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
+++ b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
@@ -47,11 +47,8 @@ describe('#_overrideConfigIsRequired', function () {
it('should make isRequired = false for kerberos properties', function () {
instanceObject.overrideConfigIsRequired(serviceConfig);
- // toggle isRequired to false
- configs.forEach(function(p) {
- expect(p.isRequired).to.be.false;
- expect(p.error).to.be.false;
- });
+ expect(configs.everyProperty('isRequired', false)).to.be.true;
+ expect(configs.everyProperty('error', false)).to.be.true;
});
it('should make isRequired = true for kerberos properties', function () {
@@ -59,9 +56,6 @@ describe('#_overrideConfigIsRequired', function () {
instanceObject.overrideConfigIsRequired(serviceConfig);
// toggle to true
instanceObject.overrideConfigIsRequired(serviceConfig);
-
- configs.forEach(function(p) {
- expect(p.isRequired).to.be.true;
- });
+ expect(configs.everyProperty('isRequired', true)).to.be.true;
});
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
index 20f6b76..e3a1960 100644
--- a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
+++ b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
@@ -52,18 +52,25 @@ describe('App.KDCCredentialsControllerMixin', function() {
message: 'Only temporary store available, config should be disabled, and appropriate hint shown'
}
].forEach(function(test) {
- it(test.message, function() {
- var configs = [],
- config;
- mixedObject.reopen({
- isStorePersisted: function() {
- return test.isStorePersisted;
- }.property()
+ describe(test.message, function() {
+
+ var config;
+
+ beforeEach(function () {
+ var configs = [];
+ mixedObject.reopen({
+ isStorePersisted: function() {
+ return test.isStorePersisted;
+ }.property()
+ });
+ mixedObject.initilizeKDCStoreProperties(configs);
+ config = configs.findProperty('name', 'persist_credentials');
});
- mixedObject.initilizeKDCStoreProperties(configs);
- config = configs.findProperty('name', 'persist_credentials');
- Em.keys(test.e).forEach(function(key) {
- assert.equal(Em.get(config, key), test.e[key], 'validate attribute: ' + key);
+
+ Object.keys(test.e).forEach(function(key) {
+ it(key, function () {
+ assert.equal(Em.get(config, key), test.e[key], 'validate attribute: ' + key);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mixins/common/serverValidator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/serverValidator_test.js b/ambari-web/test/mixins/common/serverValidator_test.js
index c6d528a..aac91b0 100644
--- a/ambari-web/test/mixins/common/serverValidator_test.js
+++ b/ambari-web/test/mixins/common/serverValidator_test.js
@@ -121,11 +121,17 @@ describe('App.ServerValidatorMixin', function() {
});
tests.forEach(function(test) {
- it(test.message, function() {
- instanceObject.set('stepConfigs', test.stepConfigs);
- instanceObject.validationSuccess({resources: test.resources});
+ describe(test.message, function() {
+
+ beforeEach(function () {
+ instanceObject.set('stepConfigs', test.stepConfigs);
+ instanceObject.validationSuccess({resources: test.resources});
+ });
+
test.expected.forEach(function(e) {
- expect(instanceObject).to.have.deep.property(e.prop, e.value);
+ it(e.prop + ': ' + e.value, function () {
+ expect(instanceObject).to.have.deep.property(e.prop, e.value);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/models/cluster_states_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/cluster_states_test.js b/ambari-web/test/models/cluster_states_test.js
index d07845f..96a1832 100644
--- a/ambari-web/test/models/cluster_states_test.js
+++ b/ambari-web/test/models/cluster_states_test.js
@@ -57,14 +57,24 @@ describe('App.clusterStatus', function () {
});
describe('#getUserPrefSuccessCallback', function () {
- it('should set the cluster parameters', function () {
- status.getUserPrefSuccessCallback(response);
+ describe('response', function () {
+ beforeEach(function () {
+ status.getUserPrefSuccessCallback(response);
+ });
Em.keys(response).forEach(function (key) {
- expect(status.get(key)).to.equal(response[key]);
+ it(key, function () {
+ expect(status.get(key)).to.equal(response[key]);
+ });
+ });
+ });
+ describe('compressedResponse', function () {
+ beforeEach(function () {
+ status.getUserPrefSuccessCallback(compressedResponse);
});
- status.getUserPrefSuccessCallback(compressedResponse);
Em.keys(response2).forEach(function (key) {
- expect(status.get(key)).to.equal(response2[key]);
+ it(key, function () {
+ expect(status.get(key)).to.equal(response2[key]);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 2b4a297..b8a6f4e 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -289,17 +289,13 @@ describe('App.ServiceConfigProperty', function () {
describe('#isPropertyOverridable', function () {
overridableFalseData.forEach(function (item) {
it('should be false', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isPropertyOverridable')).to.be.false;
});
});
overridableTrueData.forEach(function (item) {
it('should be true', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isPropertyOverridable')).to.be.true;
});
});
@@ -308,17 +304,13 @@ describe('App.ServiceConfigProperty', function () {
describe('#isOverridden', function () {
overriddenFalseData.forEach(function (item) {
it('should be false', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isOverridden')).to.be.false;
});
});
overriddenTrueData.forEach(function (item) {
it('should be true', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isOverridden')).to.be.true;
});
});
@@ -327,17 +319,13 @@ describe('App.ServiceConfigProperty', function () {
describe('#isRemovable', function () {
removableFalseData.forEach(function (item) {
it('should be false', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isRemovable')).to.be.false;
});
});
removableTrueData.forEach(function (item) {
it('should be true', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isRemovable')).to.be.true;
});
});
@@ -345,10 +333,14 @@ describe('App.ServiceConfigProperty', function () {
describe('#init', function () {
initPropertyData.forEach(function (item) {
- it('should set initial data', function () {
- serviceConfigPropertyInit = App.ServiceConfigProperty.create(item.initial);
+ describe('should set initial data for ' + JSON.stringify(item), function () {
+ beforeEach(function () {
+ serviceConfigPropertyInit = App.ServiceConfigProperty.create(item.initial);
+ });
Em.keys(item.result).forEach(function (prop) {
- expect(serviceConfigPropertyInit.get(prop)).to.equal(item.result[prop]);
+ it(prop, function () {
+ expect(serviceConfigPropertyInit.get(prop)).to.equal(item.result[prop]);
+ });
});
});
});
@@ -357,9 +349,7 @@ describe('App.ServiceConfigProperty', function () {
describe('#isNotDefaultValue', function () {
notDefaultFalseData.forEach(function (item) {
it('should be false', function () {
- Em.keys(item).forEach(function (prop) {
- serviceConfigProperty.set(prop, item[prop]);
- });
+ serviceConfigProperty.setProperties(item);
expect(serviceConfigProperty.get('isNotDefaultValue')).to.be.false;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/router_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/router_test.js b/ambari-web/test/router_test.js
index de4b77a..7bd2c80 100644
--- a/ambari-web/test/router_test.js
+++ b/ambari-web/test/router_test.js
@@ -94,49 +94,49 @@ describe('App.Router', function () {
window.location.replace.restore();
});
- it('should redirect to the latest version of admin view', function() {
- var tests = [{
- mockData: {
- components: [{
- 'RootServiceComponents': {
- 'component_version': '1.9.0'
- }
- }, {
- 'RootServiceComponents': {
- 'component_version': '2.0.0'
- }
- }]
- },
- expected: '/views/ADMIN_VIEW/2.0.0/INSTANCE/#/'
- }, {
- mockData: {
- components: [{
- 'RootServiceComponents': {
- 'component_version': '1.9.0'
- }
- }, {
- 'RootServiceComponents': {
- 'component_version': '2.1.0'
- }
- }, {
- 'RootServiceComponents': {
- 'component_version': '2.0.0'
- }
- }]
- },
- expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
- }, {
- mockData: {
- versions: [{
- 'RootServiceComponents': {
- version: '2.1.0'
- }
- }]
- },
- expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
- }];
+ var tests = [{
+ mockData: {
+ components: [{
+ 'RootServiceComponents': {
+ 'component_version': '1.9.0'
+ }
+ }, {
+ 'RootServiceComponents': {
+ 'component_version': '2.0.0'
+ }
+ }]
+ },
+ expected: '/views/ADMIN_VIEW/2.0.0/INSTANCE/#/'
+ }, {
+ mockData: {
+ components: [{
+ 'RootServiceComponents': {
+ 'component_version': '1.9.0'
+ }
+ }, {
+ 'RootServiceComponents': {
+ 'component_version': '2.1.0'
+ }
+ }, {
+ 'RootServiceComponents': {
+ 'component_version': '2.0.0'
+ }
+ }]
+ },
+ expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
+ }, {
+ mockData: {
+ components: [{
+ 'RootServiceComponents': {
+ component_version: '2.1.0'
+ }
+ }]
+ },
+ expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
+ }];
- tests.forEach(function(data) {
+ tests.forEach(function(data, index) {
+ it('should redirect to the latest version of admin view ("' + data.expected + '") #' + (index + 1), function () {
router.adminViewInfoSuccessCallback(data.mockData);
expect(window.location.replace.calledWith(data.expected)).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/ajax/ajax_queue_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/ajax/ajax_queue_test.js b/ambari-web/test/utils/ajax/ajax_queue_test.js
index 89c7f61..10c3299 100644
--- a/ambari-web/test/utils/ajax/ajax_queue_test.js
+++ b/ambari-web/test/utils/ajax/ajax_queue_test.js
@@ -91,7 +91,7 @@ describe('App.ajaxQueue', function () {
it('for empty queue App.ajax.send shouldn\'t be called', function() {
ajaxQueue.clear();
ajaxQueue.runNextRequest();
- expect(App.ajax.send.called).to.equal(false);
+ expect(App.ajax.send.called).to.equal(false); // eslint-disable-line mocha-cleanup/disallowed-usage
});
it('when queue is empty finishedCallback should be called', function() {
ajaxQueue.clear();
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index b58bfa3..0df828e 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -673,10 +673,10 @@ describe('App.config', function () {
var group = Em.Object.create({name: "group1"});
- it('creates override with save properties as original config', function() {
- var override = App.config.createOverride(configProperty, {}, group);
- Object.keys(template).forEach(function (key) {
- expect(override.get(key)).to.eql(template[key]);
+ Object.keys(template).forEach(function (key) {
+ it(key, function () {
+ var override = App.config.createOverride(configProperty, {}, group);
+ expect(override.get(key)).to.equal(template[key]);
});
});
@@ -699,19 +699,19 @@ describe('App.config', function () {
});
});
- it('overrides some specific values', function() {
- var overridenTemplate = {
- value: "v2",
- recommendedValue: "rv2",
- savedValue: "sv2",
- isFinal: true,
- recommendedIsFinal: false,
- savedIsFinal: true
- };
+ var overriddenTemplate = {
+ value: "v2",
+ recommendedValue: "rv2",
+ savedValue: "sv2",
+ isFinal: true,
+ recommendedIsFinal: false,
+ savedIsFinal: true
+ };
- var override = App.config.createOverride(configProperty, overridenTemplate, group);
- Object.keys(overridenTemplate).forEach(function (key) {
- expect(override.get(key)).to.eql(overridenTemplate[key]);
+ Object.keys(overriddenTemplate).forEach(function (key) {
+ it('overrides some specific values `' + key + '`', function () {
+ var override = App.config.createOverride(configProperty, overriddenTemplate, group);
+ expect(override.get(key)).to.equal(overriddenTemplate[key]);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/date/timezone_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/date/timezone_test.js b/ambari-web/test/utils/date/timezone_test.js
index f372fa6..da89586 100644
--- a/ambari-web/test/utils/date/timezone_test.js
+++ b/ambari-web/test/utils/date/timezone_test.js
@@ -94,27 +94,25 @@ describe('timezoneUtils', function () {
describe('#getAllTimezoneNames', function () {
- before(function () {
- this.result = timezoneUtils.getAllTimezoneNames();
- });
-
- after(function () {
- this.result = undefined;
- });
+ var result = timezoneUtils.getAllTimezoneNames();
it('timezone names are parsed', function () {
expect(this.result).to.have.length.above(0);
});
- it('Etc/* are excluded', function () {
- this.result.forEach(function (tz) {
- expect(tz.indexOf('Etc/')).to.equal(-1);
+ describe('Etc/* are excluded', function () {
+ result.forEach(function (tz) {
+ it(tz, function () {
+ expect(tz.indexOf('Etc/')).to.equal(-1);
+ });
});
});
- it('Abbreviations are excluded', function () {
- this.result.forEach(function (tz) {
- expect(tz).to.not.equal(tz.toUpperCase());
+ describe('Abbreviations are excluded', function () {
+ result.forEach(function (tz) {
+ it(tz, function () {
+ expect(tz).to.not.equal(tz.toUpperCase());
+ });
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/helper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/helper_test.js b/ambari-web/test/utils/helper_test.js
index 5d8bc40..2b43f28 100644
--- a/ambari-web/test/utils/helper_test.js
+++ b/ambari-web/test/utils/helper_test.js
@@ -180,11 +180,7 @@ describe('utils/helper', function() {
expect(testable.length).to.eql(result.length);
});
it('should sort array', function() {
- result.forEach(function(resultObj, index, resultArr) {
- if (index > resultArr.length - 1) {
- expect(resultObj.a < resultArr[index + 1].a).to.be.equal(false);
- }
- });
+ expect(result.mapProperty('a')).to.be.eql([1, 2, 3, 3, 6, 64]);
});
it('should try to sort without throwing exception', function(){
expect(testable.sortPropertyLight(['a'])).to.ok;
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/common/chart/linear_time_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/chart/linear_time_test.js b/ambari-web/test/views/common/chart/linear_time_test.js
index 202a6ad..7d76520 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -379,12 +379,18 @@ describe('App.ChartLinearTimeView', function () {
});
cases.forEach(function (item) {
- it(item.title || item.displayUnit, function () {
- view.set('displayUnit', item.displayUnit);
- view.setYAxisFormatter();
- view.yAxisFormatter();
+ describe(item.title || item.displayUnit, function () {
+
+ beforeEach(function () {
+ view.set('displayUnit', item.displayUnit);
+ view.setYAxisFormatter();
+ view.yAxisFormatter();
+ });
+
methodNames.forEach(function (name) {
- expect(App.ChartLinearTimeView[name].callCount).to.equal(Number(name === item.formatter));
+ it(name, function () {
+ expect(App.ChartLinearTimeView[name].callCount).to.equal(Number(name === item.formatter));
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/common/configs/service_config_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_config_view_test.js b/ambari-web/test/views/common/configs/service_config_view_test.js
index f0757a3..8a01d72 100644
--- a/ambari-web/test/views/common/configs/service_config_view_test.js
+++ b/ambari-web/test/views/common/configs/service_config_view_test.js
@@ -80,12 +80,18 @@ describe('App.ServiceConfigView', function () {
});
testCases.forEach(function (test) {
- it(test.title, function () {
- controller.set('selectedService', test.selectedService);
- controller.set('selectedConfigGroup', test.selectedConfigGroup);
- view.checkCanEdit();
- controller.get('selectedService.configCategories').forEach(function (category) {
- expect(category.get('canAddProperty')).to.equal(test.result[category.get('name')]);
+ describe(test.title, function () {
+
+ beforeEach(function () {
+ controller.set('selectedService', test.selectedService);
+ controller.set('selectedConfigGroup', test.selectedConfigGroup);
+ view.checkCanEdit();
+ });
+ Object.keys(test.result).forEach(function (categoryName) {
+ it(categoryName, function () {
+ var canAddProperty = controller.get('selectedService.configCategories').findProperty('name', categoryName).get('canAddProperty');
+ expect(canAddProperty).to.be.equal(test.result[categoryName]);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/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 232c267..71e602a 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
@@ -257,15 +257,19 @@ describe('App.showClusterCheckPopup', function () {
popup.onPrimary();
});
- it('result', function () {
+ describe('result', function () {
Em.keys(item.result).forEach(function (key) {
- expect(popup[key]).to.equal(item.result[key]);
+ it(key, function () {
+ expect(popup[key]).to.equal(item.result[key]);
+ });
});
});
- it('bodyResult', function () {
+ describe('bodyResult', function () {
Em.keys(item.bodyResult).forEach(function (key) {
- expect(popupBody[key]).to.eql(item.bodyResult[key]);
+ it(key, function () {
+ expect(popupBody[key]).to.eql(item.bodyResult[key]);
+ });
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
index 43c05ad..63382bd 100644
--- a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
+++ b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
@@ -102,15 +102,18 @@ describe('App.ManageAlertNotificationsView', function () {
}
}
]).forEach(function (test) {
- it(test.m, function () {
- Em.keys(test.p).forEach(function (k) {
- view.set(k, test.p[k]);
+ describe(test.m, function () {
+ beforeEach(function () {
+ view.setProperties(test.p);
+ view.set('controller.selectedAlertNotification', test.selectedAlertNotification);
+ App.isOperator = test.isOperator;
+ view.buttonObserver();
});
- view.set('controller.selectedAlertNotification', test.selectedAlertNotification);
- App.isOperator = test.isOperator;
- view.buttonObserver();
+
Em.keys(test.e).forEach(function (k) {
- expect(view.get(k)).to.equal(test.e[k]);
+ it(k, function () {
+ expect(view.get(k)).to.equal(test.e[k]);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/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 bb4c6cb..6d0d0b6 100644
--- a/ambari-web/test/views/wizard/step3_view_test.js
+++ b/ambari-web/test/views/wizard/step3_view_test.js
@@ -20,9 +20,8 @@ var App = require('app');
require('messages');
require('views/wizard/step3_view');
var v;
-describe('App.WizardStep3View', function () {
-
- var view = App.WizardStep3View.create({
+function getView() {
+ return App.WizardStep3View.create({
monitorStatuses: function () {
},
content: [
@@ -46,6 +45,11 @@ describe('App.WizardStep3View', function () {
return this.get('content');
}.property('content')
});
+}
+
+describe('App.WizardStep3View', function () {
+
+ var view = getView();
describe('#watchSelection', function () {
it('2 of 3 hosts selected', function () {
@@ -240,13 +244,22 @@ describe('App.WizardStep3View', function () {
]);
describe('#countCategoryHosts', function () {
+ var _view;
testCases.forEach(function (test) {
- it(test.title, function () {
- view.set('content', test.content);
- view.countCategoryHosts();
- view.get('categories').forEach(function (category) {
- expect(category.get('hostsCount')).to.equal(test.result[category.get('hostsBootStatus')])
- })
+ describe(test.title, function () {
+
+ beforeEach(function () {
+ _view = getView();
+ _view.set('content', test.content);
+ _view.countCategoryHosts();
+ });
+
+ Object.keys(test.result).forEach(function (categoryName) {
+ it('`' + categoryName + '`', function () {
+ expect(_view.get('categories').findProperty('hostsBootStatus', categoryName).get('hostsCount')).to.be.equal(test.result[categoryName])
+ });
+ });
+
});
}, this);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/wizard/step9_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step9_view_test.js b/ambari-web/test/views/wizard/step9_view_test.js
index b9c0182..646e945 100644
--- a/ambari-web/test/views/wizard/step9_view_test.js
+++ b/ambari-web/test/views/wizard/step9_view_test.js
@@ -20,20 +20,23 @@ var App = require('app');
require('views/wizard/step9_view');
var v;
+function getView() {
+ return App.WizardStep9View.create({
+ onStatus: function () {},
+ content: [],
+ pageContent: function () {
+ return this.get('content');
+ }.property('content')
+ });
+}
+
describe('App.WizardStep9View', function () {
beforeEach(function () {
v = App.WizardStep9View.create({
controller: App.WizardStep9Controller.create()
});
});
- var view = App.WizardStep9View.create({
- onStatus: function () {
- },
- content: [],
- pageContent: function () {
- return this.get('content');
- }.property('content')
- });
+ var view = getView();
var testCases = [
{
title: 'none hosts',
@@ -194,12 +197,20 @@ describe('App.WizardStep9View', function () {
describe('#countCategoryHosts', function () {
testCases.forEach(function (test) {
- it(test.title, function () {
- view.set('content', test.content);
- view.countCategoryHosts();
- view.get('categories').forEach(function (category) {
- expect(category.get('hostsCount')).to.equal(test.result[category.get('hostStatus')])
- })
+ describe(test.title, function () {
+ var _v;
+ beforeEach(function () {
+ _v = getView();
+ _v.set('content', test.content);
+ _v.countCategoryHosts();
+ });
+
+ Object.keys(test.result).forEach(function (categoryName) {
+ it('`' + categoryName + '`', function () {
+ expect(_v.get('categories').findProperty('hostStatus', categoryName).get('hostsCount')).to.equal(test.result[categoryName])
+ });
+ });
+
});
}, this);
});
@@ -375,11 +386,17 @@ describe('App.WizardStep9View', function () {
}
}
]).forEach(function (test) {
- it(test.status, function () {
- v.set('controller.status', test.status);
- v.onStatus();
- Em.keys(test.e).forEach(function (k) {
- expect(v.get(k)).to.equal(test.e[k]);
+ describe(test.status, function () {
+
+ beforeEach(function () {
+ v.set('controller.status', test.status);
+ v.onStatus();
+ });
+
+ Object.keys(test.e).forEach(function (k) {
+ it(k, function () {
+ expect(v.get(k)).to.equal(test.e[k]);
+ });
});
});
});
@@ -636,11 +653,17 @@ describe('App.HostStatusView', function () {
}
}
]).forEach(function (test) {
- it(JSON.stringify(test.obj), function () {
- hv.set('obj', test.obj);
- hv.onStatus();
- Em.keys(test.e).forEach(function (k) {
- expect(hv.get(k)).to.equal(test.e[k]);
+ describe(JSON.stringify(test.obj), function () {
+
+ beforeEach(function () {
+ hv.set('obj', test.obj);
+ hv.onStatus();
+ });
+
+ Object.keys(test.e).forEach(function (k) {
+ it(k, function () {
+ expect(hv.get(k)).to.equal(test.e[k]);
+ });
});
});
});