AMBARI-14531. Improve Ambari UI UT (p.4) (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b8aede2a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b8aede2a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b8aede2a Branch: refs/heads/trunk Commit: b8aede2a8e57cff8bb981064dbec13951a969679 Parents: 09406ac Author: Oleg Nechiporenko <[email protected]> Authored: Thu Dec 31 15:24:20 2015 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu Dec 31 15:24:20 2015 +0200 ---------------------------------------------------------------------- .../global/update_controller_test.js | 28 +- ambari-web/test/controllers/installer_test.js | 248 ++++++------ .../nameNode/step3_controller_test.js | 28 +- .../nameNode/step4_controller_test.js | 23 +- .../admin/stack_and_upgrade_controller_test.js | 64 +-- .../definitions_configs_controller_test.js | 86 ++-- .../heatmap_metrics/heatmap_metric_test.js | 56 ++- .../controllers/main/charts/heatmap_test.js | 40 +- .../main/host/add_controller_test.js | 246 +++++++----- .../test/controllers/main/host/details_test.js | 155 +++++--- .../main/service/add_controller_test.js | 22 +- .../main/service/info/summary_test.js | 35 +- .../test/controllers/main/service/item_test.js | 111 +++--- .../manage_config_groups_controller_test.js | 109 +++-- .../service/reassign/step4_controller_test.js | 18 +- .../test/controllers/main/service_test.js | 27 +- .../test/controllers/wizard/step10_test.js | 34 +- .../test/controllers/wizard/step3_test.js | 71 +++- .../test/controllers/wizard/step4_test.js | 106 ++--- .../test/controllers/wizard/step5_test.js | 29 +- .../test/controllers/wizard/step6_test.js | 194 +++++---- .../test/controllers/wizard/step7_test.js | 141 ++++--- .../test/controllers/wizard/step8_test.js | 397 +++++++++++-------- .../test/controllers/wizard/step9_test.js | 145 ++++--- ambari-web/test/controllers/wizard_test.js | 7 +- ambari-web/test/helpers.js | 2 + .../test/mappers/stack_service_mapper_test.js | 2 + .../test/mixins/common/serverValidator_test.js | 29 +- ambari-web/test/models/form_test.js | 3 +- ambari-web/test/utils/config_test.js | 45 ++- .../utils/configs/config_initializer_test.js | 63 ++- .../configs/widgets/config_widget_view_test.js | 83 ++-- .../widgets/list_config_widget_view_test.js | 16 +- .../widgets/slider_config_widget_view_test.js | 45 ++- .../widgets/toggle_config_widget_view_test.js | 4 +- .../test/views/common/controls_view_test.js | 35 +- .../views/common/rolling_restart_view_test.js | 27 +- .../stack_upgrade/upgrade_wizard_view_test.js | 28 +- .../select_definitions_popup_body_view_test.js | 26 +- .../test/views/main/dashboard/widget_test.js | 57 ++- .../test/views/main/dashboard/widgets_test.js | 26 +- ambari-web/test/views/main/host/details_test.js | 8 +- ambari-web/test/views/wizard/step5_view_test.js | 19 +- 43 files changed, 1773 insertions(+), 1165 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/global/update_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js index 010e30a..6a95871 100644 --- a/ambari-web/test/controllers/global/update_controller_test.js +++ b/ambari-web/test/controllers/global/update_controller_test.js @@ -427,16 +427,24 @@ describe('App.UpdateController', function () { }); cases.forEach(function (item) { - it(item.title, function () { - appGetMock.withArgs('router.mainAdminStackAndUpgradeController').returns(Em.Object.create({ - loadUpgradeData: mock.loadUpgradeData, - isLoadUpgradeDataPending: item.isLoadUpgradeDataPending - })).withArgs('wizardIsNotFinished').returns(item.wizardIsNotFinished) - .withArgs('router.currentState.name').returns(item.currentStateName) - .withArgs('router.currentState.parentState.name').returns(item.parentStateName);; - controller.updateUpgradeState(mock.callback); - expect(mock.loadUpgradeData.callCount).to.equal(item.loadUpgradeDataCallCount); - expect(mock.callback.callCount).to.equal(item.callbackCallCount); + describe(item.title, function () { + + beforeEach(function () { + appGetMock.withArgs('router.mainAdminStackAndUpgradeController').returns(Em.Object.create({ + loadUpgradeData: mock.loadUpgradeData, + isLoadUpgradeDataPending: item.isLoadUpgradeDataPending + })).withArgs('wizardIsNotFinished').returns(item.wizardIsNotFinished) + .withArgs('router.currentState.name').returns(item.currentStateName) + .withArgs('router.currentState.parentState.name').returns(item.parentStateName); + controller.updateUpgradeState(mock.callback); + }); + it('loadUpgradeData is called ' + item.loadUpgradeDataCallCount + ' times', function () { + expect(mock.loadUpgradeData.callCount).to.equal(item.loadUpgradeDataCallCount); + }); + it('callback is called ' + item.callbackCallCount + ' times', function () { + expect(mock.callback.callCount).to.equal(item.callbackCallCount); + }); + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/installer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js index 65b911c..65b19ab 100644 --- a/ambari-web/test/controllers/installer_test.js +++ b/ambari-web/test/controllers/installer_test.js @@ -94,38 +94,38 @@ describe('App.InstallerController', function () { }); describe('#checkRepoURL', function() { - + var stacks = Em.A([ + Em.Object.create({ + isSelected: false + }), + Em.Object.create({ + isSelected: true, + reload: false, + id: 'nn-cc', + repositories: Em.A([ + Em.Object.create({ + isSelected: true + }) + ]), + operatingSystems: Em.A([ + Em.Object.create({ + isSelected: true, + repositories: Em.A([ + Em.Object.create({ + errorTitle: '1', + errorContent: '1', + validation: '' + }) + ]) + }) + ]) + }) + ]); + var wizard = Em.Object.create({ + skipValidationChecked: true + }); it ('Should reload installed stacks', function() { - var stacks = Em.A([ - Em.Object.create({ - isSelected: false - }), - Em.Object.create({ - isSelected: true, - reload: false, - id: 'nn-cc', - repositories: Em.A([ - Em.Object.create({ - isSelected: true - }) - ]), - operatingSystems: Em.A([ - Em.Object.create({ - isSelected: true, - repositories: Em.A([ - Em.Object.create({ - errorTitle: '1', - errorContent: '1', - validation: '' - }) - ]) - }) - ]) - }) - ]); - var wizard = Em.Object.create({ - skipValidationChecked: true - }); + installerController.set('content.stacks', stacks); installerController.checkRepoURL(wizard); @@ -164,47 +164,48 @@ describe('App.InstallerController', function () { }); describe('#checkRepoURLSuccessCallback', function() { - it ('Should check stacks for sucess', function() { - var stacks = Em.A([ - Em.Object.create({ - isSelected: false - }), - Em.Object.create({ - isSelected: true, - reload: false, - id: 'nn-cc', - repositories: Em.A([ - Em.Object.create({ - repoId: 11, - isSelected: true - }) - ]), - operatingSystems: Em.A([ - Em.Object.create({ - isSelected: true, - id: 1, - repositories: Em.A([ - Em.Object.create({ - repoId: 11, - errorTitle: '1', - errorContent: '1', - validation: '' - }) - ]) - }) - ]) - }) - ]); - var resolve = false; - var data = { - osId: 1, - repoId: 11, - dfd: { - resolve: function() { - resolve = true; - } + var stacks = Em.A([ + Em.Object.create({ + isSelected: false + }), + Em.Object.create({ + isSelected: true, + reload: false, + id: 'nn-cc', + repositories: Em.A([ + Em.Object.create({ + repoId: 11, + isSelected: true + }) + ]), + operatingSystems: Em.A([ + Em.Object.create({ + isSelected: true, + id: 1, + repositories: Em.A([ + Em.Object.create({ + repoId: 11, + errorTitle: '1', + errorContent: '1', + validation: '' + }) + ]) + }) + ]) + }) + ]); + var data = { + osId: 1, + repoId: 11, + dfd: { + resolve: function() { + resolve = true; } - }; + } + }; + var resolve = false; + it ('Should check stacks for sucess', function() { + installerController.set('content.stacks', stacks); installerController.checkRepoURLSuccessCallback(null,null,data); @@ -246,47 +247,48 @@ describe('App.InstallerController', function () { }); describe('#checkRepoURLErrorCallback', function() { - it ('Should check stacks for error', function() { - var stacks = Em.A([ - Em.Object.create({ - isSelected: false - }), - Em.Object.create({ - isSelected: true, - reload: false, - id: 'nn-cc', - repositories: Em.A([ - Em.Object.create({ - repoId: 11, - isSelected: true - }) - ]), - operatingSystems: Em.A([ - Em.Object.create({ - isSelected: true, - id: 1, - repositories: Em.A([ - Em.Object.create({ - repoId: 11, - errorTitle: '1', - errorContent: '1', - validation: '' - }) - ]) - }) - ]) - }) - ]); - var resolve = false; - var data = { - osId: 1, - repoId: 11, - dfd: { - reject: function() { - resolve = true; - } + var stacks = Em.A([ + Em.Object.create({ + isSelected: false + }), + Em.Object.create({ + isSelected: true, + reload: false, + id: 'nn-cc', + repositories: Em.A([ + Em.Object.create({ + repoId: 11, + isSelected: true + }) + ]), + operatingSystems: Em.A([ + Em.Object.create({ + isSelected: true, + id: 1, + repositories: Em.A([ + Em.Object.create({ + repoId: 11, + errorTitle: '1', + errorContent: '1', + validation: '' + }) + ]) + }) + ]) + }) + ]); + var data = { + osId: 1, + repoId: 11, + dfd: { + reject: function() { + resolve = true; } - }; + } + }; + var resolve = false; + it ('Should check stacks for error', function() { + var req = { status: 500, statusText: 'error' @@ -351,7 +353,8 @@ describe('App.InstallerController', function () { }); describe('#setLowerStepsDisable', function() { - it ('Should disable lower steps', function() { + + beforeEach(function () { var steps = Em.A([ Em.Object.create({ step: 0, @@ -376,6 +379,9 @@ describe('App.InstallerController', function () { ]); installerController.set('isStepDisabled', steps); installerController.setLowerStepsDisable(3); + }); + + it ('Should disable lower steps', function() { var expected = [ { "step": 0, @@ -398,15 +404,14 @@ describe('App.InstallerController', function () { "value": false } ]; - var res = JSON.parse(JSON.stringify(installerController.get('isStepDisabled'))); - expect(res).to.eql(expected); }); }); describe('#setStepsEnable', function() { - it ('Should enable next steps', function() { + + beforeEach(function () { var steps = Em.A([ Em.Object.create({ step: 0, @@ -432,6 +437,9 @@ describe('App.InstallerController', function () { installerController.set('isStepDisabled', steps); installerController.totalSteps = steps.length - 1; installerController.set('currentStep',2); + }); + + it ('Should enable next steps', function() { var expected = [ { "step": 0, @@ -454,9 +462,7 @@ describe('App.InstallerController', function () { "value": true } ]; - var res = JSON.parse(JSON.stringify(installerController.get('isStepDisabled'))); - expect(res).to.eql(expected); }); }); @@ -827,8 +833,10 @@ describe('App.InstallerController', function () { }); describe('#saveClients', function() { - it ('Should return correct clients names', function() { - var stepController = Em.Object.create({ + var stepController; + + beforeEach(function () { + stepController = Em.Object.create({ content: Em.A([ Em.Object.create({ isInstalled: true, @@ -864,6 +872,8 @@ describe('App.InstallerController', function () { }) ]) }); + }); + it ('Should return correct clients names', function() { installerController.saveClients(stepController); var res = JSON.parse(JSON.stringify(installerController.get('content.clients'))); expect(res).to.eql([ http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js index aff4413..1b0fe31 100644 --- a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js +++ b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js @@ -329,15 +329,27 @@ describe('App.HighAvailabilityWizardStep3Controller', function() { value: nameServiceId + '/hawq_default' } ]).forEach(function (test) { - it(test.config.name, function () { - test.config.displayName = test.config.name; - var configs = [test.config]; - configs = controller.tweakServiceConfigs(configs); - expect(configs[0].value).to.equal(test.value); - expect(configs[0].recommendedValue).to.equal(test.value); + describe(test.config.name, function () { + var configs; + beforeEach(function () { + test.config.displayName = test.config.name; + configs = controller.tweakServiceConfigs([test.config]); + }); + + it('value is ' + test.value, function () { + expect(configs[0].value).to.equal(test.value); + }); + it('recommendedValue is ' + test.value, function () { + expect(configs[0].recommendedValue).to.equal(test.value); + }); + if(test.name) { - expect(configs[0].name).to.equal(test.name); - expect(configs[0].displayName).to.equal(test.name); + it('name is ' + test.name, function () { + expect(configs[0].name).to.equal(test.name); + }); + it('displayNamr is' + test.name, function () { + expect(configs[0].displayName).to.equal(test.name); + }); } }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js index 1136052..d5ab8d2 100644 --- a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js +++ b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js @@ -92,13 +92,22 @@ describe('App.HighAvailabilityWizardStep4Controller', function() { ]; tests.forEach(function(test) { - it(test.m, function() { - this.controller.set('isNameNodeStarted', !test.e.isNameNodeStarted); - this.controller.checkNnCheckPointStatus(test.responseData); - this.clock.tick(this.controller.get('POLL_INTERVAL')); - expect(this.controller.get('isNameNodeStarted')).to.be.eql(test.e.isNameNodeStarted); - expect(this.controller.get('isNextEnabled')).to.be.eql(test.e.isNextEnabled); - expect(this.controller.pullCheckPointStatus.called).to.be.eql(test.e.isPollingCalled); + describe(test.m, function() { + + beforeEach(function () { + this.controller.set('isNameNodeStarted', !test.e.isNameNodeStarted); + this.controller.checkNnCheckPointStatus(test.responseData); + this.clock.tick(this.controller.get('POLL_INTERVAL')); + }); + it('isNameNodeStarted is ' + test.e.isNameNodeStarted, function () { + expect(this.controller.get('isNameNodeStarted')).to.be.equal(test.e.isNameNodeStarted); + }); + it('isNextEnabled is ' + test.e.isNextEnabled, function () { + expect(this.controller.get('isNextEnabled')).to.be.equal(test.e.isNextEnabled); + }); + it('pullCheckPointStatus is ' + (test.e.isPollingCalled ? '' : 'not') + ' called', function () { + expect(this.controller.pullCheckPointStatus.called).to.be.equal(test.e.isPollingCalled); + }); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js index 2651437..23652ed 100644 --- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js +++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js @@ -2088,20 +2088,12 @@ describe('App.MainAdminStackAndUpgradeController', function() { focus: function () {} }; - before(function(){ + beforeEach(function(){ sinon.stub(window, 'open', function () { return mock; }); sinon.spy(mock.document, 'write'); sinon.spy(mock, 'focus'); - }); - - after(function(){ - window.open.restore(); - }); - - it("should open window and write table to it", function () { - controller.openConfigsInNewWindow({ context: [ { @@ -2120,29 +2112,43 @@ describe('App.MainAdminStackAndUpgradeController', function() { } ] }); + }); + + afterEach(function(){ + window.open.restore(); + mock.document.write.restore(); + mock.focus.restore(); + }); + it('new window is open', function () { expect(window.open.calledOnce).to.be.true; + }); + + it('new window content is valid', function () { expect(mock.document.write.calledWith('<table style="text-align: left;"><thead><tr>' + - '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' + - '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' + - '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.currentValue') + '</th>' + - '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.recommendedValue') + '</th>' + - '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.resultingValue') + '</th>' + - '</tr></thead><tbody>' + - '<tr>' + - '<td>' + 'type1' + '</td>' + - '<td>' + 'name1' + '</td>' + - '<td>' + 'currentValue1' + '</td>' + - '<td>' + 'recommendedValue1' + '</td>' + - '<td>' + 'resultingValue1' + '</td>' + - '</tr>' + - '<tr>' + - '<td>' + 'type2' + '</td>' + - '<td>' + 'name2' + '</td>' + - '<td>' + 'currentValue2' + '</td>' + - '<td>' + 'recommendedValue2' + '</td>' + - '<td>' + 'resultingValue2' + '</td>' + - '</tr></tbody></table>')).to.be.true; + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' + + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' + + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.currentValue') + '</th>' + + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.recommendedValue') + '</th>' + + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.resultingValue') + '</th>' + + '</tr></thead><tbody>' + + '<tr>' + + '<td>' + 'type1' + '</td>' + + '<td>' + 'name1' + '</td>' + + '<td>' + 'currentValue1' + '</td>' + + '<td>' + 'recommendedValue1' + '</td>' + + '<td>' + 'resultingValue1' + '</td>' + + '</tr>' + + '<tr>' + + '<td>' + 'type2' + '</td>' + + '<td>' + 'name2' + '</td>' + + '<td>' + 'currentValue2' + '</td>' + + '<td>' + 'recommendedValue2' + '</td>' + + '<td>' + 'resultingValue2' + '</td>' + + '</tr></tbody></table>')).to.be.true; + }); + + it('document.focus is called once', function () { expect(mock.focus.calledOnce).to.be.true; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js index f39f7bf..f2f77aa 100644 --- a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js @@ -93,8 +93,7 @@ describe('App.MainAlertDefinitionConfigsController', function () { describe('#renderPortConfigs()', function () { - it('should render array of configs with correct values', function () { - + beforeEach(function () { controller.set('content', Em.Object.create({ name: 'alertDefinitionName', service: {displayName: 'alertDefinitionService'}, @@ -119,15 +118,17 @@ describe('App.MainAlertDefinitionConfigsController', function () { uri: 'alertDefinitionUri', defaultPort: '777' })); + }); + it('isWizard = true', function () { controller.set('isWizard', true); var result = controller.renderPortConfigs(); - expect(result.length).to.equal(11); + }); + it('isWizard = false', function () { controller.set('isWizard', false); - result = controller.renderPortConfigs(); - + var result = controller.renderPortConfigs(); expect(result.length).to.equal(5); }); @@ -135,8 +136,7 @@ describe('App.MainAlertDefinitionConfigsController', function () { describe('#renderMetricConfigs()', function () { - it('should render array of configs with correct values', function () { - + beforeEach(function () { controller.set('content', Em.Object.create({ name: 'alertDefinitionName', service: {displayName: 'alertDefinitionService'}, @@ -174,15 +174,17 @@ describe('App.MainAlertDefinitionConfigsController', function () { value: null } })); + }); + it('isWizard = true', function () { controller.set('isWizard', true); var result = controller.renderMetricConfigs(); - expect(result.length).to.equal(11); + }); + it('isWizard = false', function () { controller.set('isWizard', false); - result = controller.renderMetricConfigs(); - + var result = controller.renderMetricConfigs(); expect(result.length).to.equal(5); }); @@ -190,8 +192,7 @@ describe('App.MainAlertDefinitionConfigsController', function () { describe('#renderWebConfigs()', function () { - it('should render array of configs with correct values', function () { - + beforeEach(function () { controller.set('content', Em.Object.create({ name: 'alertDefinitionName', service: {displayName: 'alertDefinitionService'}, @@ -221,15 +222,17 @@ describe('App.MainAlertDefinitionConfigsController', function () { "default_port": 0.0 } })); + }); + it('isWizard = true', function () { controller.set('isWizard', true); var result = controller.renderWebConfigs(); - expect(result.length).to.equal(11); + }); + it('isWizard = false', function () { controller.set('isWizard', false); - result = controller.renderWebConfigs(); - + var result = controller.renderWebConfigs(); expect(result.length).to.equal(5); }); @@ -237,8 +240,7 @@ describe('App.MainAlertDefinitionConfigsController', function () { describe('#renderScriptConfigs()', function () { - it('should render array of configs with correct values', function () { - + beforeEach(function () { controller.set('content', Em.Object.create({ name: 'alertDefinitionName', service: {displayName: 'alertDefinitionService'}, @@ -262,15 +264,17 @@ describe('App.MainAlertDefinitionConfigsController', function () { ], location: 'path to script' })); + }); + it('isWizard = true', function () { controller.set('isWizard', true); var result = controller.renderScriptConfigs(); - expect(result.length).to.equal(8); + }); + it('isWizard = false', function () { controller.set('isWizard', false); - result = controller.renderScriptConfigs(); - + var result = controller.renderScriptConfigs(); expect(result.length).to.equal(2); }); @@ -309,20 +313,23 @@ describe('App.MainAlertDefinitionConfigsController', function () { describe('#editConfigs()', function () { - it('should set previousValue, isDisabled for each config and change canEdit flag', function () { - + beforeEach(function () { controller.set('configs', [ Em.Object.create({value: 'value1', previousValue: '', isDisabled: true}), Em.Object.create({value: 'value2', previousValue: '', isDisabled: true}), Em.Object.create({value: 'value3', previousValue: '', isDisabled: true}) ]); - controller.set('canEdit', false); - controller.editConfigs(); + }); + it('should set previousValue', function () { expect(controller.get('configs').mapProperty('previousValue')).to.eql(['value1', 'value2', 'value3']); + }); + it('should set isDisabled for each config', function () { expect(controller.get('configs').someProperty('isDisabled', true)).to.be.false; + }); + it('should change canEdit flag', function () { expect(controller.get('canEdit')).to.be.true; }); @@ -330,20 +337,23 @@ describe('App.MainAlertDefinitionConfigsController', function () { describe('#cancelEditConfigs()', function () { - it('should set previousValue, isDisabled for each config and change canEdit flag', function () { - + beforeEach(function () { controller.set('configs', [ Em.Object.create({value: '', previousValue: 'value1', isDisabled: false}), Em.Object.create({value: '', previousValue: 'value2', isDisabled: false}), Em.Object.create({value: '', previousValue: 'value3', isDisabled: false}) ]); - controller.set('canEdit', true); - controller.cancelEditConfigs(); + }); + it('should set previousValue', function () { expect(controller.get('configs').mapProperty('value')).to.eql(['value1', 'value2', 'value3']); + }); + it('should set isDisabled for each config', function () { expect(controller.get('configs').someProperty('isDisabled', false)).to.be.false; + }); + it('should change canEdit flag', function () { expect(controller.get('canEdit')).to.be.false; }); @@ -353,26 +363,26 @@ describe('App.MainAlertDefinitionConfigsController', function () { beforeEach(function () { sinon.spy(App.ajax, 'send'); - }); - - afterEach(function () { - App.ajax.send.restore(); - }); - - it('should set previousValue, isDisabled for each config and change canEdit flag', function () { - controller.set('configs', [ Em.Object.create({isDisabled: true}), Em.Object.create({isDisabled: true}), Em.Object.create({isDisabled: true}) ]); - controller.set('canEdit', true); - controller.saveConfigs(); + }); + afterEach(function () { + App.ajax.send.restore(); + }); + + it('should set isDisabled for each config', function () { expect(controller.get('configs').someProperty('isDisabled', false)).to.be.false; + }); + it('should change canEdit flag', function () { expect(controller.get('canEdit')).to.be.false; + }); + it('should sent 1 request', function () { expect(App.ajax.send.calledOnce).to.be.true; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js index 2babb01..8d724d2 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js @@ -47,32 +47,54 @@ describe('MainChartHeatmapMetric', function () { describe('#slotDefinitions', function () { beforeEach(function () { sinon.stub(mainChartHeatmapMetric, 'generateSlot', Em.K); + mainChartHeatmapMetric.set('maximumValue', 100); + mainChartHeatmapMetric.set('minimumValue', 0); }); afterEach(function () { mainChartHeatmapMetric.generateSlot.restore(); }); - it('one slot', function () { - mainChartHeatmapMetric.set('numberOfSlots', 1); - mainChartHeatmapMetric.set('maximumValue', 100); - mainChartHeatmapMetric.set('minimumValue', 0); - mainChartHeatmapMetric.propertyDidChange('slotDefinitions'); + describe('one slot', function () { + + beforeEach(function () { + mainChartHeatmapMetric.set('numberOfSlots', 1); + mainChartHeatmapMetric.propertyDidChange('slotDefinitions'); + this.slotDefinitions = mainChartHeatmapMetric.get('slotDefinitions'); + }); + + it('3 slotDefinitions', function () { + expect(this.slotDefinitions.length).to.equal(3); + }); + it('generateSlot is called 1 time', function () { + expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(1); + }); + it('generateSlot is called with correct arguments', function () { + expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 100, '', {r: 0, g: 204, b: 0}]); + }); - expect(mainChartHeatmapMetric.get('slotDefinitions').length).to.equal(3); - expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 100, '', {r: 0, g: 204, b: 0}]); - expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(1); }); - it('two slots', function () { - mainChartHeatmapMetric.set('numberOfSlots', 2); - mainChartHeatmapMetric.set('maximumValue', 100); - mainChartHeatmapMetric.set('minimumValue', 0); - mainChartHeatmapMetric.propertyDidChange('slotDefinitions'); + describe('two slots', function () { + + beforeEach(function () { + mainChartHeatmapMetric.set('numberOfSlots', 2); + mainChartHeatmapMetric.propertyDidChange('slotDefinitions'); + this.slotDefinitions = mainChartHeatmapMetric.get('slotDefinitions'); + }); + + it('4 slotDefinitions', function () { + expect(this.slotDefinitions.length).to.equal(4); + }); + it('generateSlot is called 2 times', function () { + expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(2); + }); + it('generateSlot 1st call has valid arguments', function () { + expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 50, '', {r: 0, g: 204, b: 0}]); + }); + it('generateSlot 2nd call has valid arguments', function () { + expect(mainChartHeatmapMetric.generateSlot.getCall(1).args).to.eql([50, 100, '', {r: 159, g: 238, b: 0}]); + }); - expect(mainChartHeatmapMetric.get('slotDefinitions').length).to.equal(4); - expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 50, '', {r: 0, g: 204, b: 0}]); - expect(mainChartHeatmapMetric.generateSlot.getCall(1).args).to.eql([50, 100, '', {r: 159, g: 238, b: 0}]); - expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(2); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/charts/heatmap_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_test.js b/ambari-web/test/controllers/main/charts/heatmap_test.js index 2e3f9de..ec87ace 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_test.js @@ -206,20 +206,32 @@ describe('MainChartsHeatmapController', function () { expect(categories[0].get('heatmaps')).to.eql(allHeatmaps); }); - it("two categories", function() { - var allHeatmaps = [ - { - metrics: JSON.stringify([{service_name: 'S1'}]) - }, - { - metrics: JSON.stringify([{service_name: 'S1'}]) - } - ]; - var categories = controller.categorizeByServiceName(allHeatmaps); - expect(categories[0].get('serviceName')).to.equal('S1'); - expect(categories[0].get('displayName')).to.equal('S1'); - expect(categories[0].get('heatmaps')[0]).to.eql(allHeatmaps[0]); - expect(categories[0].get('heatmaps')[1]).to.eql(allHeatmaps[1]); + describe("two categories", function() { + var allHeatmaps; + beforeEach(function () { + allHeatmaps = [ + { + metrics: JSON.stringify([{service_name: 'S1'}]) + }, + { + metrics: JSON.stringify([{service_name: 'S1'}]) + } + ]; + this.categories = controller.categorizeByServiceName(allHeatmaps); + }); + + it('serviceName is S1', function () { + expect(this.categories[0].get('serviceName')).to.equal('S1'); + }); + it('displayName is S1', function () { + expect(this.categories[0].get('displayName')).to.equal('S1'); + }); + it('heatmaps.0 is valid', function () { + expect(this.categories[0].get('heatmaps')[0]).to.eql(allHeatmaps[0]); + }); + it('heatmaps.1 is valid', function () { + expect(this.categories[0].get('heatmaps')[1]).to.eql(allHeatmaps[1]); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/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 ea9d032..6dcb2c9 100644 --- a/ambari-web/test/controllers/main/host/add_controller_test.js +++ b/ambari-web/test/controllers/main/host/add_controller_test.js @@ -418,6 +418,7 @@ describe('App.AddHostController', function () { stack: [], model: [] }; + beforeEach(function () { sinon.stub(controller, 'getDBProperty', function () { return services.db; @@ -430,111 +431,164 @@ describe('App.AddHostController', function () { }); sinon.stub(controller, 'setDBProperty', Em.K); }); + afterEach(function () { controller.getDBProperty.restore(); App.StackService.find.restore(); App.Service.find.restore(); controller.setDBProperty.restore(); }); - it("No services in db, no installed services", function () { - services.stack = [Em.Object.create({ - serviceName: 'S1' - })]; - controller.loadServices(); - expect(controller.setDBProperty.getCall(0).args).to.eql(['services', - { - selectedServices: [], - installedServices: [] + + Em.A([ + { + m: 'No services in db, no installed services', + service: { + db: null, + stack: [Em.Object.create({ + serviceName: 'S1' + })], + model: [] + }, + e: { + + db: ['services', + { + selectedServices: [], + installedServices: [] + } + ], + services: [ + Em.Object.create({ + serviceName: 'S1', + isInstalled: false, + isSelected: false + }) + ] } - ]); - expect(controller.get('content.services')).to.eql([ - Em.Object.create({ - serviceName: 'S1', - isInstalled: false, - isSelected: false - }) - ]) - }); - it("No services in db, installed service present", function () { - services.stack = [ - Em.Object.create({ - serviceName: 'S1' - }), - Em.Object.create({ - serviceName: 'S2' - }) - ]; - services.model = [ - Em.Object.create({ - serviceName: 'S1' - }) - ]; - controller.loadServices(); - expect(controller.setDBProperty.getCall(0).args).to.eql(['services', - { - selectedServices: ['S1'], - installedServices: ['S1'] + }, + { + m: 'No services in db, installed service present', + service: { + db: null, + stack: [ + Em.Object.create({ + serviceName: 'S1' + }), + Em.Object.create({ + serviceName: 'S2' + }) + ], + model: [ + Em.Object.create({ + serviceName: 'S1' + }) + ] + }, + e: { + db: ['services', + { + selectedServices: ['S1'], + installedServices: ['S1'] + } + ], + services: [ + Em.Object.create({ + serviceName: 'S1', + isInstalled: true, + isSelected: true + }), + Em.Object.create({ + serviceName: 'S2', + isInstalled: false, + isSelected: false + }) + ] } - ]); - expect(controller.get('content.services')).to.eql([ - Em.Object.create({ - serviceName: 'S1', - isInstalled: true, - isSelected: true - }), - Em.Object.create({ - serviceName: 'S2', - isInstalled: false, - isSelected: false - }) - ]); - }); - it("DB is empty", function () { - services.stack = [Em.Object.create({ - serviceName: 'S1' - })]; - services.db = { - selectedServices: [], - installedServices: [] - }; - controller.loadServices(); - expect(controller.setDBProperty.called).to.be.false; - expect(controller.get('content.services')).to.eql([ - Em.Object.create({ - serviceName: 'S1', - isSelected: false, - isInstalled: false - }) - ]); - }); - it("DB has selected and installed services", function () { - services.stack = [ - Em.Object.create({ - serviceName: 'S1' - }), - Em.Object.create({ - serviceName: 'S2' - }) - ]; - services.db = { - selectedServices: ['S1'], - installedServices: ['S2'] - }; - controller.loadServices(); - expect(controller.setDBProperty.called).to.be.false; - expect(controller.get('content.services')).to.eql([ - Em.Object.create({ - serviceName: 'S1', - isInstalled: false, - isSelected: true - }), - Em.Object.create({ - serviceName: 'S2', - isInstalled: true, - isSelected: false - }) - ]); + }, + { + m: 'DB is empty', + service: { + db: { + selectedServices: [], + installedServices: [] + }, + stack: [Em.Object.create({ + serviceName: 'S1' + })], + model: [] + }, + e: { + db: false, + services: [ + Em.Object.create({ + serviceName: 'S1', + isSelected: false, + isInstalled: false + }) + ] + } + }, + { + m: 'DB has selected and installed services', + service: { + db: { + selectedServices: ['S1'], + installedServices: ['S2'] + }, + stack: [ + Em.Object.create({ + serviceName: 'S1' + }), + Em.Object.create({ + serviceName: 'S2' + }) + ], + model: [] + }, + e: { + db: false, + services: [ + Em.Object.create({ + serviceName: 'S1', + isInstalled: false, + isSelected: true + }), + Em.Object.create({ + serviceName: 'S2', + isInstalled: true, + isSelected: false + }) + ] + } + } + ]).forEach(function (test) { + + describe(test.m, function () { + + beforeEach(function () { + services = test.service; + controller.loadServices(); + }); + + it('services are valid', function () { + expect(controller.get('content.services')).to.be.eql(test.e.services); + }); + + if (test.e.db) { + it('setDBProperty is called with valid arguments', function () { + expect(controller.setDBProperty.getCall(0).args).to.eql(test.e.db); + }); + } + else { + it('setDBProperty is not called', function () { + expect(controller.setDBProperty.called).to.be.false; + }); + } + + }); + }); + }); describe("#loadSlaveComponentHosts()", function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index 27bd38f..2aaa35f 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -152,51 +152,71 @@ describe('App.MainHostDetailsController', function () { }); describe('#sendComponentCommand()', function () { - it('single component', function () { - controller.set('content.hostName', 'host1'); - var component = Em.Object.create({ - service: {serviceName: 'S1'}, - componentName: 'COMP1' + + describe('single component', function () { + var component; + beforeEach(function () { + controller.set('content.hostName', 'host1'); + component = Em.Object.create({ + service: {serviceName: 'S1'}, + componentName: 'COMP1' + }); + + controller.sendComponentCommand(component, {}, 'state'); }); - controller.sendComponentCommand(component, {}, 'state'); - expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_component.update'); - expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({ - "hostName": "host1", - "context": {}, - "component": component, - "HostRoles": { - "state": "state" - }, - "componentName": "COMP1", - "serviceName": "S1" + it('1st call endpoint is valid', function () { + expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_component.update'); + }); + + it('1st call data is valid', function () { + expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({ + "hostName": "host1", + "context": {}, + "component": component, + "HostRoles": { + "state": "state" + }, + "componentName": "COMP1", + "serviceName": "S1" + }); }); }); - it('multiple component', function () { - controller.set('content.hostName', 'host1'); - var component = [ - Em.Object.create({ - service: {serviceName: 'S1'}, - componentName: 'COMP1' - }), - Em.Object.create({ - service: {serviceName: 'S1'}, - componentName: 'COMP2' - }) - ]; - controller.sendComponentCommand(component, {}, 'state'); - expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_components.update'); - expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({ - "hostName": "host1", - "context": {}, - "component": component, - "HostRoles": { - "state": "state" - }, - "query": "HostRoles/component_name.in(COMP1,COMP2)" + describe('multiple component', function () { + var component; + beforeEach(function () { + controller.set('content.hostName', 'host1'); + component = [ + Em.Object.create({ + service: {serviceName: 'S1'}, + componentName: 'COMP1' + }), + Em.Object.create({ + service: {serviceName: 'S1'}, + componentName: 'COMP2' + }) + ]; + controller.sendComponentCommand(component, {}, 'state'); + }); + + it('1st call endpoint is valid', function () { + expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_components.update'); + }); + + it('1st call data is valid', function () { + expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({ + "hostName": "host1", + "context": {}, + "component": component, + "HostRoles": { + "state": "state" + }, + "query": "HostRoles/component_name.in(COMP1,COMP2)" + }); }); }); + }); describe('#sendComponentCommandSuccessCallback()', function () { @@ -3013,24 +3033,49 @@ describe('App.MainHostDetailsController', function () { afterEach(function () { controller._doDeleteHostComponent.restore(); }); - it("Host has no components", function () { - controller.set('content.hostComponents', Em.A([])); - controller.doDeleteHost(Em.K); - expect(controller.get('fromDeleteHost')).to.be.true; - expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1'); - expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host'); + + describe("Host has no components", function () { + + beforeEach(function () { + controller.set('content.hostComponents', Em.A([])); + controller.doDeleteHost(Em.K); + }); + + it('fromDeleteHost is true', function () { + expect(controller.get('fromDeleteHost')).to.be.true; + }); + it('1st request is to delete host', function () { + expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host'); + }); + it('1st request is done with valid hostName', function () { + expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1'); + }); }); - it("Host has components", function () { - controller.set('content.hostComponents', Em.A([Em.Object.create({ - componentName: 'COMP1' - })])); - controller.doDeleteHost(Em.K); - expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({ - componentName: 'COMP1' - }))).to.be.true; - expect(controller.get('fromDeleteHost')).to.be.true; - expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1'); - expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host'); + + describe("Host has components", function () { + + beforeEach(function () { + controller.set('content.hostComponents', Em.A([Em.Object.create({ + componentName: 'COMP1' + })])); + controller.doDeleteHost(Em.K); + }); + + it('_doDeleteHostComponent is called with correct arguments', function () { + expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({ + componentName: 'COMP1' + }))).to.be.true; + }); + it('fromDeleteHost is true', function () { + expect(controller.get('fromDeleteHost')).to.be.true; + }); + it('1st request is to delete host', function () { + expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host'); + }); + it('1st request is done with valid hostName', function () { + expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1'); + }); + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/service/add_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js index 1ec367e..601d7d8 100644 --- a/ambari-web/test/controllers/main/service/add_controller_test.js +++ b/ambari-web/test/controllers/main/service/add_controller_test.js @@ -63,13 +63,23 @@ describe('App.AddServiceController', function() { App.get.restore(); }); - it('send request to install client', function () { - addServiceController.set("content.additionalClients", [t.additionalClients]); - addServiceController.installAdditionalClients(); - expect($.ajax.calledOnce).to.equal(true); + describe('send request to install client', function () { + + beforeEach(function () { + addServiceController.set("content.additionalClients", [t.additionalClients]); + addServiceController.installAdditionalClients(); + }); + + it('1 request is sent', function () { + expect($.ajax.calledOnce).to.equal(true); + }); + it('data.Body is valid', function () { + expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body); + }); + it('data.RequestInfo is valid', function () { + expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo); + }); - expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body); - expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo); }); it('should not send request to install client', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/service/info/summary_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/summary_test.js b/ambari-web/test/controllers/main/service/info/summary_test.js index 28c13e3..3db7239 100644 --- a/ambari-web/test/controllers/main/service/info/summary_test.js +++ b/ambari-web/test/controllers/main/service/info/summary_test.js @@ -207,14 +207,23 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS }); cases.forEach(function (item) { - it(item.title, function () { - controller.set('isPreviousRangerConfigsCallFailed', item.isPreviousRangerConfigsCallFailed); - controller.get('rangerPlugins').findProperty('serviceName', 'HDFS').tag = item.hdfsTag; - controller.get('rangerPlugins').findProperty('serviceName', 'HBASE').tag = item.hbaseTag; - controller.getRangerPluginsStatus(data); - expect(App.ajax.send.calledOnce).to.equal(item.ajaxRequestSent); + describe(item.title, function () { + + beforeEach(function () { + controller.set('isPreviousRangerConfigsCallFailed', item.isPreviousRangerConfigsCallFailed); + controller.get('rangerPlugins').findProperty('serviceName', 'HDFS').tag = item.hdfsTag; + controller.get('rangerPlugins').findProperty('serviceName', 'HBASE').tag = item.hbaseTag; + controller.getRangerPluginsStatus(data); + }); + + it('1 request is ' + item.ajaxRequestSent + ' sent', function () { + expect(App.ajax.send.calledOnce).to.equal(item.ajaxRequestSent); + }); + if (item.ajaxRequestSent) { - expect(App.ajax.send.getCall(0).args[0].data.urlParams.contains('ranger-yarn-plugin-properties')).to.be.false; + it('request does not contains `ranger-yarn-plugin-properties`', function () { + expect(App.ajax.send.getCall(0).args[0].data.urlParams.contains('ranger-yarn-plugin-properties')).to.be.false; + }); } }); }); @@ -222,7 +231,8 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS }); describe('#getRangerPluginsStatusSuccess', function () { - it('relevant plugin statuses are set', function () { + + beforeEach(function () { controller.getRangerPluginsStatusSuccess({ 'items': [ { @@ -245,9 +255,18 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS } ] }); + }); + + it('isPreviousRangerConfigsCallFailed is false', function () { expect(controller.get('isPreviousRangerConfigsCallFailed')).to.be.false; + }); + it('rangerPlugins.HDFS status is valid', function () { expect(controller.get('rangerPlugins').findProperty('serviceName', 'HDFS').status).to.equal(Em.I18n.t('alerts.table.state.enabled')); + }); + it('rangerPlugins.HIVE status is valid', function () { expect(controller.get('rangerPlugins').findProperty('serviceName', 'HIVE').status).to.equal(Em.I18n.t('alerts.table.state.enabled')); + }); + it('rangerPlugins.HBASE status is valid', function () { expect(controller.get('rangerPlugins').findProperty('serviceName', 'HBASE').status).to.equal(Em.I18n.t('common.unknown')); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/service/item_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js index 4be23c9..8b2f24e 100644 --- a/ambari-web/test/controllers/main/service/item_test.js +++ b/ambari-web/test/controllers/main/service/item_test.js @@ -304,25 +304,30 @@ describe('App.MainServiceItemController', function () { tests.forEach(function (test, index) { - function setupWithTestData() { - mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}}); - mainServiceItemController.startStopPopupPrimary(test.data.state, test.data.query); - } + describe('case #' + (index + 1), function () { + + beforeEach(function () { + mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}}); + mainServiceItemController.startStopPopupPrimary(test.data.state, test.data.query); + this.data = JSON.parse($.ajax.args[0][0].data); + }); + + it('request is sent with valid data ' + (index + 1), function () { + expect($.ajax.calledOnce).to.equal(true); + expect(this.data.Body.ServiceInfo.state).to.equal(test.request.Body.ServiceInfo.state); + expect(this.data.RequestInfo.context).to.equal(test.request.RequestInfo.context); + }); + + it('isStopDisabled is true ' + (index + 1), function () { + expect(mainServiceItemController.get('isStopDisabled')).to.equal(true); + }); + + it('isStartDisabled is true ' + (index + 1), function () { + expect(mainServiceItemController.get('isStartDisabled')).to.equal(true); + }); - it('request is sent with valid data ' + (index + 1), function () { - setupWithTestData(); - expect($.ajax.calledOnce).to.equal(true); - expect(JSON.parse($.ajax.args[0][0].data).Body.ServiceInfo.state).to.equal(test.request.Body.ServiceInfo.state); - expect(JSON.parse($.ajax.args[0][0].data).RequestInfo.context).to.equal(test.request.RequestInfo.context); - }); - it('isStopDisabled is true ' + (index + 1), function () { - setupWithTestData(); - expect(mainServiceItemController.get('isStopDisabled')).to.equal(true); - }); - it('isStartDisabled is true ' + (index + 1), function () { - setupWithTestData(); - expect(mainServiceItemController.get('isStartDisabled')).to.equal(true); }); + }); @@ -517,37 +522,53 @@ describe('App.MainServiceItemController', function () { expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.not.be.ok; }); - it ("should display dependent list if other services depend on the one to be stopped", function() { - var mainServiceItemController = App.MainServiceItemController.create( - {content: { - serviceName: "HDFS", - passiveState:'OFF', - hostComponents: [{ - componentName: 'NAMENODE', - workStatus: 'INSTALLED' - }] - }} - ); - mainServiceItemController.startStopPopup(event, "INSTALLED"); - expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.turnOnMM')).to.be.ok; - expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok; - - var dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HDFS", "HBase,YARN") - var msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HDFS"); - var fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", msg, "HDFS"); - expect(fullMsg).to.be.equal(msg + " " + dependencies); + describe ("should display dependent list if other services depend on the one to be stopped", function() { + var mainServiceItemController; + beforeEach(function () { + mainServiceItemController = App.MainServiceItemController.create( + {content: { + serviceName: "HDFS", + passiveState:'OFF', + hostComponents: [{ + componentName: 'NAMENODE', + workStatus: 'INSTALLED' + }] + }} + ); + mainServiceItemController.startStopPopup(event, "INSTALLED"); + this.dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HDFS", "HBase,YARN"); + this.msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HDFS"); + this.fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HDFS"); + }); + + it('turnOnMM message is shown', function () { + expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.turnOnMM')).to.be.ok; + }); + it('message about dependent services is shown', function () { + expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok; + }); + it('full message is valid', function () { + expect(this.fullMsg).to.be.equal(this.msg + " " + this.dependencies); + }); }); - it ("should display the dependent service if another service depends on the one to be stopped", function() { - var mainServiceItemController = App.MainServiceItemController.create( + describe("should display the dependent service if another service depends on the one to be stopped", function() { + + beforeEach(function () { + var mainServiceItemController = App.MainServiceItemController.create( {content: {serviceName: "HIVE", passiveState:'OFF'}}); - mainServiceItemController.startStopPopup(event, "INSTALLED"); - expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok; - - var dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HIVE", "Spark") - var msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HIVE"); - var fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", msg, "HIVE"); - expect(fullMsg).to.be.equal(msg + " " + dependencies); + mainServiceItemController.startStopPopup(event, "INSTALLED"); + this.dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HIVE", "Spark"); + this.msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HIVE"); + this.fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HIVE"); + }); + + it('message about dependent services is shown', function () { + expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok; + }); + it('full message is valid', function () { + expect(this.fullMsg).to.be.equal(this.msg + " " + this.dependencies); + }); }); afterEach(function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js index 699f0a2..0cc0f5f 100644 --- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js +++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js @@ -442,6 +442,58 @@ describe('App.ManageConfigGroupsController', function() { describe('#_onLoadPropertiesSuccess', function () { + var data = { + items: [ + { + type: 'type1', + tag: 'tag1', + properties: { + prop1: 'val1', + prop2: 'val2' + } + }, + { + type: 'type1', + tag: 'tag2', + properties: { + prop3: 'val3' + } + }, + { + type: 'type2', + tag: 'tag1', + properties: { + prop4: 'val4' + } + } + ] + }; + var params = { + typeTagToGroupMap: { + 'type1///tag1': 'group1', + 'type1///tag2': 'group2', + 'type2///tag1': 'group3' + } + }; + var configGroups = [ + Em.Object.create({ + name: 'group1', + properties: [] + }), + Em.Object.create({ + name: 'group2', + properties: [] + }), + Em.Object.create({ + name: 'group3', + properties: [] + }), + Em.Object.create({ + name: 'group4', + properties: [] + }) + ]; + beforeEach(function () { sinon.stub(c, 'resortConfigGroup', Em.K); }); @@ -451,63 +503,8 @@ describe('App.ManageConfigGroupsController', function() { }); it('should set properties to config groups', function () { - - c.set('configGroups', [ - Em.Object.create({ - name: 'group1', - properties: [] - }), - Em.Object.create({ - name: 'group2', - properties: [] - }), - Em.Object.create({ - name: 'group3', - properties: [] - }), - Em.Object.create({ - name: 'group4', - properties: [] - }) - ]); - - var data = { - items: [ - { - type: 'type1', - tag: 'tag1', - properties: { - prop1: 'val1', - prop2: 'val2' - } - }, - { - type: 'type1', - tag: 'tag2', - properties: { - prop3: 'val3' - } - }, - { - type: 'type2', - tag: 'tag1', - properties: { - prop4: 'val4' - } - } - ] - }; - - var params = { - typeTagToGroupMap: { - 'type1///tag1': 'group1', - 'type1///tag2': 'group2', - 'type2///tag1': 'group3' - } - }; - + c.set('configGroups', configGroups); c._onLoadPropertiesSuccess(data, null, params); - expect(JSON.stringify(c.get('configGroups'))).to.equal(JSON.stringify([ Em.Object.create({ properties: [ http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js index 19d9201..7ea47c6 100644 --- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js @@ -934,28 +934,22 @@ describe('App.ReassignMasterWizardStep4Controller', function () { describe('#startNameNode()', function () { beforeEach(function () { sinon.stub(controller, 'updateComponent', Em.K); + controller.set('content.masterComponentHosts', [{ + component: 'NAMENODE', + hostName: 'host1' + }]); }); afterEach(function () { controller.updateComponent.restore(); }); it('reassign host does not match current', function () { - controller.set('content.masterComponentHosts', [{ - component: 'NAMENODE', - hostName: 'host1' - }]); controller.set('content.reassignHosts.source', 'host2'); controller.startNameNode(); - expect(controller.updateComponent.getCall(0).args[1][0]).to.equal('host1'); - expect(controller.updateComponent.getCall(0).args[0]).to.equal('NAMENODE'); - expect(controller.updateComponent.getCall(0).args[2]).to.equal('HDFS'); - expect(controller.updateComponent.getCall(0).args[3]).to.equal('Start'); + expect(controller.updateComponent.calledWith('NAMENODE', ['host1'], 'HDFS', 'Start')).to.be.true; }); + it('reassign host matches current', function () { - controller.set('content.masterComponentHosts', [{ - component: 'NAMENODE', - hostName: 'host1' - }]); controller.set('content.reassignHosts.source', 'host1'); controller.startNameNode(); expect(controller.updateComponent.calledWith('NAMENODE', [], 'HDFS', 'Start')).to.be.true; http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/main/service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js index 4a3d329..3c90b9d 100644 --- a/ambari-web/test/controllers/main/service_test.js +++ b/ambari-web/test/controllers/main/service_test.js @@ -273,6 +273,9 @@ describe('App.MainServiceController', function () { describe('#allServicesCall', function() { + var state = 'STARTED', + query = 'some query'; + beforeEach(function() { sinon.stub($, 'ajax', Em.K); sinon.stub(App, 'get', function(k) { @@ -280,6 +283,9 @@ describe('App.MainServiceController', function () { if ('clusterName' === k) return 'tdk'; return Em.get(App, k); }); + mainServiceController.allServicesCall(state, query); + this.params = $.ajax.args[0][0]; + this.data = JSON.parse(this.params.data); }); afterEach(function() { @@ -287,16 +293,17 @@ describe('App.MainServiceController', function () { App.get.restore(); }); - it('should do ajax-request', function() { - var state = 'STARTED', - query = 'some query'; - mainServiceController.allServicesCall(state, query); - var params = $.ajax.args[0][0]; - expect(params.type).to.equal('PUT'); - expect(params.url.contains('/clusters/tdk/services?')).to.be.true; - var data = JSON.parse(params.data); - expect(data.Body.ServiceInfo.state).to.equal(state); - expect(data.RequestInfo.context).to.equal(App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES); + it('PUT request is sent', function() { + expect(this.params.type).to.equal('PUT'); + }); + it('request is sent to `/services`', function() { + expect(this.params.url.contains('/clusters/tdk/services?')).to.be.true; + }); + it('Body.ServiceInfo.state is ' + state, function() { + expect(this.data.Body.ServiceInfo.state).to.equal(state); + }); + it('RequestInfo.context is ' + query, function() { + expect(this.data.RequestInfo.context).to.equal(App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/wizard/step10_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step10_test.js b/ambari-web/test/controllers/wizard/step10_test.js index d6ce4b4..92743c3 100644 --- a/ambari-web/test/controllers/wizard/step10_test.js +++ b/ambari-web/test/controllers/wizard/step10_test.js @@ -158,12 +158,19 @@ describe('App.WizardStep10Controller', function () { } ]); tests.forEach(function(test) { - it(test.m, function() { - controller.set('content.hosts', test.hosts); - controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})])); - controller.loadInstalledHosts(); + describe(test.m, function() { + + beforeEach(function () { + controller.set('content.hosts', test.hosts); + controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})])); + controller.loadInstalledHosts(); + }); + test.e.forEach(function(ex) { - expect(controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', ex.id).get('displayStatement').contains(ex.l)).to.equal(true); + it(JSON.stringify(test.e), function () { + var displayStatement = controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', ex.id).get('displayStatement'); + expect(displayStatement.contains(ex.l)).to.equal(true); + }); }); }) }); @@ -314,12 +321,19 @@ describe('App.WizardStep10Controller', function () { } ]); testsForFailedTasks.forEach(function(test) { - it(test.m, function() { - controller.set('content.hosts', test.hosts); - controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})])); - controller.loadInstalledHosts(); + describe(test.m, function() { + + beforeEach(function () { + controller.set('content.hosts', test.hosts); + controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})])); + controller.loadInstalledHosts(); + }); + test.e.forEach(function(ex) { - expect(controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').mapProperty('status', ex.st).length).to.equal(ex.l); + it(JSON.stringify(test.e), function () { + var tasksWithNeededStatements = controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').filterProperty('status', ex.st); + expect(tasksWithNeededStatements.length).to.equal(ex.l); + }); }); }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/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 309d658..692d292 100644 --- a/ambari-web/test/controllers/wizard/step3_test.js +++ b/ambari-web/test/controllers/wizard/step3_test.js @@ -355,17 +355,28 @@ describe('App.WizardStep3Controller', function () { ]); tests.forEach(function (test) { - it(test.m, function () { - c.set('bootHosts', test.bootHosts); - var r = c.parseHostInfo(test.hostsStatusFromServer); - expect(r).to.equal(test.e.r); + describe(test.m, function () { + var r; + beforeEach(function () { + c.set('bootHosts', test.bootHosts); + r = c.parseHostInfo(test.hostsStatusFromServer); + }); + + it('parsed hosts info is valid', function () { + expect(r).to.equal(test.e.r); + }); + if (test.e.c) { test.hostsStatusFromServer.forEach(function (h) { - var r = c.get('bootHosts').findProperty('name', h.hostName); - if (!['REGISTERED', 'REGISTERING'].contains(r.get('bootStatus'))) { - expect(r.get('bootStatus')).to.equal(h.status); - expect(r.get('bootLog')).to.equal(h.log); - } + + it('bootStatus and bootLog are valid', function () { + var bootHosts = c.get('bootHosts').findProperty('name', h.hostName); + if (!['REGISTERED', 'REGISTERING'].contains(bootHosts.get('bootStatus'))) { + expect(bootHosts.get('bootStatus')).to.equal(h.status); + expect(bootHosts.get('bootLog')).to.equal(h.log); + } + }); + }); } }); @@ -1617,15 +1628,24 @@ describe('App.WizardStep3Controller', function () { ]) } ]).forEach(function (category) { - describe(category.m, function () { - category.tests.forEach(function (test) { - it(test.m, function () { + describe(category.m, function () { + category.tests.forEach(function (test) { + + describe(test.m, function () { + + beforeEach(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('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]); @@ -1635,6 +1655,7 @@ describe('App.WizardStep3Controller', function () { }); }); }); + }); it('should parse umask warnings', function () { @@ -2081,18 +2102,26 @@ describe('App.WizardStep3Controller', function () { ]).forEach(function (category) { describe(category.m, function () { category.tests.forEach(function (test) { - it(test.m, function () { - c.parseWarnings({items: test.items}); - 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]); + describe(test.m, 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]); + }); }); }); - 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]); + + 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]); + } } - } + }); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/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 69cc727..8cd1c3f 100644 --- a/ambari-web/test/controllers/wizard/step4_test.js +++ b/ambari-web/test/controllers/wizard/step4_test.js @@ -160,19 +160,25 @@ describe('App.WizardStep4Controller', function () { ]; testCases.forEach(function(testCase){ - it(testCase.title, function () { - controller.clear(); - for(var id in testCase.condition) { - controller.pushObject(Ember.Object.create({ - 'serviceName':id, 'isSelected': testCase.condition[id], 'canBeSelected': true, 'isInstalled': false, - coSelectedServices: function() { - return App.StackService.coSelected[this.get('serviceName')] || []; - }.property('serviceName') - })); - } - controller.setGroupedServices(); + describe(testCase.title, function () { + + beforeEach(function () { + controller.clear(); + for(var id in testCase.condition) { + controller.pushObject(Ember.Object.create({ + 'serviceName':id, 'isSelected': testCase.condition[id], 'canBeSelected': true, 'isInstalled': false, + coSelectedServices: function() { + return App.StackService.coSelected[this.get('serviceName')] || []; + }.property('serviceName') + })); + } + controller.setGroupedServices(); + }); + for(var service in testCase.result) { - expect(controller.findProperty('serviceName', service).get('isSelected')).to.equal(testCase.result[service]); + it(service, function () { + expect(controller.findProperty('serviceName', service).get('isSelected')).to.equal(testCase.result[service]); + }); } }); }, this); @@ -431,26 +437,31 @@ describe('App.WizardStep4Controller', function () { }); if (test.errorsExpected) { - it('if errors detected than it should be shown', function () { + describe('if errors detected than it should be shown', function () { + var currentErrorObject; + beforeEach(function () { + currentErrorObject = c.get('errorStack').findProperty('isShown', false); + }); test.errorsExpected.forEach(function(error, index, errors) { - // validate current error - var currentErrorObject = c.get('errorStack').findProperty('isShown', false); - if (currentErrorObject) { - expect(test.errorsExpected).to.contain(currentErrorObject.id); - // show current error - var popup = c.showError(currentErrorObject); - // submit popup - popup.onPrimary(); - // onPrimaryPopupCallback should be called - expect(c.onPrimaryPopupCallback.called).to.equal(true); - // submit called - expect(c.submit.called).to.equal(true); - if (c.get('errorStack').length) { - // current error isShown flag changed to true - expect(currentErrorObject.isShown).to.equal(true); + it(error, function () { + // validate current error + if (currentErrorObject) { + expect(test.errorsExpected).to.contain(currentErrorObject.id); + // show current error + var popup = c.showError(currentErrorObject); + // submit popup + popup.onPrimary(); + // onPrimaryPopupCallback should be called + expect(c.onPrimaryPopupCallback.called).to.equal(true); + // submit called + expect(c.submit.called).to.equal(true); + if (c.get('errorStack').length) { + // current error isShown flag changed to true + expect(currentErrorObject.isShown).to.equal(true); + } + runValidations(); } - runValidations(); - } + }); }); }); } @@ -795,21 +806,26 @@ describe('App.WizardStep4Controller', function () { }); cases.forEach(function (item) { - it(item.title, function () { - this.stub.withArgs('currentStackName').returns(item.currentStackName). - withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber); - controller.set('content', generateSelectedServicesContent(item.services)); - var spark = controller.findProperty('serviceName', 'SPARK'); - if (item.services.contains('SPARK')) { - spark.setProperties({ - isSelected: item.isSparkSelected, - isInstalled: item.isSparkInstalled - }); - } else { - controller.removeObject(spark); - } - controller.sparkValidation(); - expect(controller.get('errorStack').mapProperty('id').contains('sparkWarning')).to.equal(item.isSparkWarning); + describe(item.title, function () { + beforeEach(function () { + this.stub.withArgs('currentStackName').returns(item.currentStackName). + withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber); + controller.set('content', generateSelectedServicesContent(item.services)); + var spark = controller.findProperty('serviceName', 'SPARK'); + if (item.services.contains('SPARK')) { + spark.setProperties({ + isSelected: item.isSparkSelected, + isInstalled: item.isSparkInstalled + }); + } else { + controller.removeObject(spark); + } + controller.sparkValidation(); + }); + + it('sparkWarning is ' + item.sparkWarning, function () { + expect(controller.get('errorStack').mapProperty('id').contains('sparkWarning')).to.equal(item.isSparkWarning); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/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 09da19e..033b067 100644 --- a/ambari-web/test/controllers/wizard/step5_test.js +++ b/ambari-web/test/controllers/wizard/step5_test.js @@ -1104,17 +1104,24 @@ describe('App.WizardStep5Controller', function () { expect(r.mapProperty('selectedHost')).to.eql(['h1', 'h1', 'h2', 'h2', 'h3']); }); - it('some saved components exist', function() { - c.set('content.controllerName', 'addServiceController'); - c.get('multipleComponents').push('c4'); - c.set('content.masterComponentHosts', [ - {hostName: 'h3', component: 'c4'} - ]); - c.get('content.recommendations.blueprint.host_groups')[2].components.push({name: 'c4'}); - var r = c.createComponentInstallationObjects(); - expect(r.mapProperty('component_name')).to.eql(['c1', 'c2', 'c1', 'c2', 'c1', 'c4']); - expect(r.mapProperty('serviceId')).to.eql(['s1', 's2', 's1', 's2', 's1', 's2']); - expect(r.mapProperty('selectedHost')).to.eql(['h1', 'h1', 'h2', 'h2', 'h3', 'h3']); + describe('some saved components exist', function() { + + beforeEach(function () { + c.set('content.controllerName', 'addServiceController'); + c.get('multipleComponents').push('c4'); + c.set('content.masterComponentHosts', [ + {hostName: 'h3', component: 'c4'} + ]); + c.get('content.recommendations.blueprint.host_groups')[2].components.push({name: 'c4'}); + }); + + it('data contains save components', function () { + var r = c.createComponentInstallationObjects(); + expect(r.mapProperty('component_name')).to.eql(['c1', 'c2', 'c1', 'c2', 'c1', 'c4']); + expect(r.mapProperty('serviceId')).to.eql(['s1', 's2', 's1', 's2', 's1', 's2']); + expect(r.mapProperty('selectedHost')).to.eql(['h1', 'h1', 'h2', 'h2', 'h3', 'h3']); + }); + }); });
