You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/12/18 11:04:20 UTC
[1/3] ambari git commit: AMBARI-14356.
hostWarningPopupBody_view_test.js unit test failing intermittently
(onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 17f7b7127 -> 1901b395c
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/highAvailability/nameNode/step6_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/highAvailability/nameNode/step6_view_test.js b/ambari-web/test/views/main/admin/highAvailability/nameNode/step6_view_test.js
index e6c456c..88898db 100644
--- a/ambari-web/test/views/main/admin/highAvailability/nameNode/step6_view_test.js
+++ b/ambari-web/test/views/main/admin/highAvailability/nameNode/step6_view_test.js
@@ -42,7 +42,7 @@ describe('App.HighAvailabilityWizardStep6View', function () {
});
describe("#step6BodyText", function() {
- it("", function() {
+ it("step6BodyText is formatted with dependent data", function() {
view.set('controller.content.masterComponentHosts', [{
component: 'NAMENODE',
isInstalled: true,
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/highAvailability/nameNode/step8_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/highAvailability/nameNode/step8_view_test.js b/ambari-web/test/views/main/admin/highAvailability/nameNode/step8_view_test.js
index 510ad7c..df9598b 100644
--- a/ambari-web/test/views/main/admin/highAvailability/nameNode/step8_view_test.js
+++ b/ambari-web/test/views/main/admin/highAvailability/nameNode/step8_view_test.js
@@ -29,7 +29,7 @@ describe('App.HighAvailabilityWizardStep8View', function () {
});
describe("#step8BodyText", function() {
- it("", function() {
+ it("step8BodyText is formatted with dependent data", function() {
view.set('controller.content.masterComponentHosts', [
{
component: 'NAMENODE',
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/highAvailability/progress_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/highAvailability/progress_view_test.js b/ambari-web/test/views/main/admin/highAvailability/progress_view_test.js
index 2da16d9..e68c2f1 100644
--- a/ambari-web/test/views/main/admin/highAvailability/progress_view_test.js
+++ b/ambari-web/test/views/main/admin/highAvailability/progress_view_test.js
@@ -36,7 +36,7 @@ describe('App.HighAvailabilityProgressPageView', function () {
afterEach(function () {
view.get('controller').loadStep.restore();
});
- it("", function () {
+ it("loadStep is called once", function () {
view.didInsertElement();
expect(view.get('controller').loadStep.calledOnce).to.be.true;
});
@@ -119,7 +119,7 @@ describe('App.HighAvailabilityProgressPageView', function () {
afterEach(function () {
taskView.onStatus.restore();
});
- it("", function () {
+ it("onStatus is called once", function () {
taskView.didInsertElement();
expect(taskView.onStatus.calledOnce).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/stack_upgrade/failed_hosts_modal_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/failed_hosts_modal_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/failed_hosts_modal_view_test.js
index d63cca0..376d4c5 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/failed_hosts_modal_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/failed_hosts_modal_view_test.js
@@ -29,7 +29,7 @@ describe('App.FailedHostsPopupBodyView', function () {
describe("#subHeader", function() {
- it("", function() {
+ it("subHeader is formatted with hosts count", function() {
view.set('parentView.content', {
hosts: ['host1', 'host2', 'host3']
});
@@ -48,7 +48,7 @@ describe('App.FailedHostsPopupBodyView', function () {
App.format.role.restore();
});
- it("", function() {
+ it("hosts are mapped from parentView.content", function() {
view.set('parentView.content', {
hosts: ['host1', 'long.host.50.chars.commmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm'],
host_detail: {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
index bc0907e..64afed3 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
@@ -37,7 +37,7 @@ describe('App.MainAdminStackServicesView', function () {
App.StackService.find.restore();
App.Service.find.restore();
});
- it("", function () {
+ it("`isInstalled`-flag depends on App.Service", function () {
view.propertyDidChange('services');
expect(view.get('services')).to.eql([
Em.Object.create({serviceName: 'S1', isInstalled: true}),
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
index ac50eee..2aed7e9 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
@@ -27,14 +27,10 @@ describe('App.upgradeGroupView', function () {
});
describe("#toggleExpanded()", function () {
- before(function () {
+ var data;
+ beforeEach(function () {
sinon.stub(view, 'collapseLowerLevels', Em.K);
- });
- after(function () {
- view.collapseLowerLevels.restore();
- });
- it("", function () {
- var data = {
+ data = {
context: Em.Object.create({
isExpanded: true
}),
@@ -48,8 +44,17 @@ describe('App.upgradeGroupView', function () {
]
};
view.toggleExpanded(data);
+ });
+ afterEach(function () {
+ view.collapseLowerLevels.restore();
+ });
+ it("collapseLowerLevels called twice", function () {
expect(view.collapseLowerLevels.calledTwice).to.be.true;
+ });
+ it("context.isExpanded is false", function () {
expect(data.context.get('isExpanded')).to.be.false;
+ });
+ it("contexts[1][0].isExpanded is false", function () {
expect(data.contexts[1][0].get('isExpanded')).to.be.false;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
index 66e6d41..5c74d38 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
@@ -31,7 +31,7 @@ describe('App.upgradeTaskView', function () {
App.TestAliases.testAsComputedOr(view, 'showContent', ['outsideView', 'content.isExpanded']);
describe("#logTabId", function() {
- it("", function() {
+ it("depends on `elementId`", function() {
view.reopen({
elementId: 'elementId'
});
@@ -40,7 +40,7 @@ describe('App.upgradeTaskView', function () {
});
describe("#errorTabId", function() {
- it("", function() {
+ it("depends on `elementId`", function() {
view.reopen({
elementId: 'elementId'
});
@@ -49,7 +49,7 @@ describe('App.upgradeTaskView', function () {
});
describe("#logTabIdLink", function() {
- it("", function() {
+ it("depends on `logTabId`", function() {
view.reopen({
logTabId: 'elementId-log-tab'
});
@@ -58,7 +58,7 @@ describe('App.upgradeTaskView', function () {
});
describe("#errorTabIdLInk", function() {
- it("", function() {
+ it("depends on `errorTabId`", function() {
view.reopen({
errorTabId: 'elementId-error-tab'
});
@@ -73,7 +73,7 @@ describe('App.upgradeTaskView', function () {
after(function () {
view.toggleProperty.restore();
});
- it("", function () {
+ it("`errorLogOpened` is toggled", function () {
view.copyErrLog();
expect(view.toggleProperty.calledWith('errorLogOpened')).to.be.true;
});
@@ -86,7 +86,7 @@ describe('App.upgradeTaskView', function () {
after(function () {
view.toggleProperty.restore();
});
- it("", function () {
+ it("outputLogOpened is toggled", function () {
view.copyOutLog();
expect(view.toggleProperty.calledWith('outputLogOpened')).to.be.true;
});
@@ -99,7 +99,7 @@ describe('App.upgradeTaskView', function () {
after(function () {
view.openLogWindow.restore();
});
- it("", function () {
+ it("stderr is open with openLogWindow", function () {
view.set('content.stderr', 'stderr');
view.openErrorLog();
expect(view.openLogWindow.calledWith('stderr')).to.be.true;
@@ -113,7 +113,7 @@ describe('App.upgradeTaskView', function () {
after(function () {
view.openLogWindow.restore();
});
- it("", function () {
+ it("stdout is open with openLogWindow", function () {
view.set('content.stdout', 'stdout');
view.openOutLog();
expect(view.openLogWindow.calledWith('stdout')).to.be.true;
@@ -135,27 +135,36 @@ describe('App.upgradeTaskView', function () {
body: mockAppendChild
}
};
- before(function () {
+ beforeEach(function () {
sinon.stub(window, 'open').returns(mockWindow);
sinon.spy(mockWindow.document, 'write');
sinon.spy(mockWindow.document, 'close');
sinon.spy(mockWindow.document, 'createElement');
sinon.spy(mockWindow.document, 'createTextNode');
sinon.spy(mockAppendChild, 'appendChild');
+ view.openLogWindow('log');
});
- after(function () {
+ afterEach(function () {
window.open.restore();
mockWindow.document.write.restore();
mockWindow.document.close.restore();
mockWindow.document.createElement.restore();
mockWindow.document.createTextNode.restore();
+ mockAppendChild.appendChild.restore();
});
- it("", function () {
- view.openLogWindow('log');
+ it("window.open is called once", function () {
expect(window.open.calledOnce).to.be.true;
+ });
+ it("pre-element is created", function () {
expect(mockWindow.document.createElement.calledWith('pre')).to.be.true;
+ });
+ it("log-node is created", function () {
expect(mockWindow.document.createTextNode.calledWith('log')).to.be.true;
+ });
+ it("two nodes are appended", function () {
expect(mockAppendChild.appendChild.calledTwice).to.be.true;
+ });
+ it("document is closed", function () {
expect(mockWindow.document.close.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
index 9507e08..94c8fe9 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
@@ -37,6 +37,16 @@ describe('App.upgradeWizardView', function () {
});
view.removeObserver('App.clusterName', view, 'startPolling');
+ beforeEach(function () {
+ sinon.stub(App.ajax, 'send').returns({
+ complete: Em.clb
+ });
+ });
+
+ afterEach(function () {
+ App.ajax.send.restore();
+ });
+
App.TestAliases.testAsComputedOr(view, 'isManualProceedDisabled', ['!isManualDone', 'controller.requestInProgress']);
App.TestAliases.testAsComputedEqualProperties(view, 'isFinalizeItem', 'manualItem.context', 'controller.finalizeContext');
@@ -60,7 +70,7 @@ describe('App.upgradeWizardView', function () {
activeGroup: Em.Object.create()
});
});
- it("", function () {
+ it("status is updated", function () {
view.reopen({
activeStatuses: ['IN_PROGRESS'],
upgradeGroups: [Em.Object.create({
@@ -156,58 +166,66 @@ describe('App.upgradeWizardView', function () {
});
sinon.spy(view, 'doPolling');
this.clock = sinon.useFakeTimers();
+ view.doPolling();
+ this.clock.tick(App.bgOperationsUpdateInterval);
});
afterEach(function () {
view.get('controller').loadUpgradeData.restore();
view.doPolling.restore();
this.clock.restore();
});
- it("", function () {
- view.doPolling();
- this.clock.tick(App.bgOperationsUpdateInterval);
+ it("loadUpgradeData is called once", function () {
expect(view.get('controller').loadUpgradeData.calledOnce).to.be.true;
+ });
+ it("doPolling is called twice", function () {
expect(view.doPolling.calledTwice).to.be.true;
});
});
describe("#continue()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(view.get('controller'), 'setUpgradeItemStatus', Em.K);
+ view.continue({context: Em.Object.create({'status': 'HOLDING_FAILED'})});
});
- after(function () {
+ afterEach(function () {
view.get('controller').setUpgradeItemStatus.restore();
});
- it("", function () {
- view.continue({context: Em.Object.create({'status': 'HOLDING_FAILED'})});
+ it("setUpgradeItemStatus is called with correct data", function () {
expect(view.get('controller').setUpgradeItemStatus.calledWith(Em.Object.create({'status': 'HOLDING_FAILED'}), 'FAILED')).to.be.true;
+ });
+ it("isDetailsOpened is false", function () {
expect(view.get('isDetailsOpened')).to.be.false;
});
});
describe("#complete()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(view.get('controller'), 'setUpgradeItemStatus', Em.K);
+ view.complete({context: Em.Object.create({'status': 'FAILED'})});
});
- after(function () {
+ afterEach(function () {
view.get('controller').setUpgradeItemStatus.restore();
});
- it("", function () {
- view.complete({context: Em.Object.create({'status': 'FAILED'})});
+ it("setUpgradeItemStatus is called with correct data", function () {
expect(view.get('controller').setUpgradeItemStatus.calledWith(Em.Object.create({'status': 'FAILED'}), 'COMPLETED')).to.be.true;
+ });
+ it("isManualDone is false", function () {
expect(view.get('isManualDone')).to.be.false;
});
});
describe("#retry()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(view.get('controller'), 'setUpgradeItemStatus', Em.K);
+ view.retry({context: Em.Object.create({'status': 'FAILED'})});
});
- after(function () {
+ afterEach(function () {
view.get('controller').setUpgradeItemStatus.restore();
});
- it("", function () {
- view.retry({context: Em.Object.create({'status': 'FAILED'})});
+ it("setUpgradeItemStatus is called with correct data", function () {
expect(view.get('controller').setUpgradeItemStatus.calledWith(Em.Object.create({'status': 'FAILED'}), 'PENDING')).to.be.true;
+ });
+ it("isDetailsOpened is false", function () {
expect(view.get('isDetailsOpened')).to.be.false;
});
});
@@ -226,7 +244,7 @@ describe('App.upgradeWizardView', function () {
});
describe("#resetManualDone()", function() {
- it("", function() {
+ it("isManualDone is set to false", function() {
view.set('isManualDone', true);
view.propertyDidChange('manualItem');
expect(view.get('isManualDone')).to.be.false;
@@ -417,7 +435,7 @@ describe('App.upgradeWizardView', function () {
after(function () {
view.toggleProperty.restore();
});
- it("", function () {
+ it("isDetailsOpened is toggled", function () {
view.toggleDetails();
expect(view.toggleProperty.calledWith('isDetailsOpened')).to.be.true;
});
@@ -658,15 +676,6 @@ describe('App.upgradeWizardView', function () {
beforeEach(function () {
view.set('controller.upgradeId', 1);
- sinon.stub(App.ajax, 'send').returns({
- complete: function (callback) {
- callback();
- }
- });
- });
-
- afterEach(function () {
- App.ajax.send.restore();
});
cases.forEach(function (item) {
@@ -775,7 +784,7 @@ describe('App.upgradeWizardView', function () {
});
describe("#failedHostsMessage", function() {
- it("", function() {
+ it("is formatted with slaveComponentStructuredInfo", function() {
view.set('controller.slaveComponentStructuredInfo', {
hosts: ['host1']
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index 50fb21a..4561449 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -226,7 +226,7 @@ describe('App.mainAdminStackVersionsView', function () {
after(function () {
view.observesCategories.restore();
});
- it("", function() {
+ it("observesCategories is called once", function() {
view.didInsertElement();
expect(view.observesCategories.calledOnce).to.be.true;
});
@@ -234,19 +234,11 @@ describe('App.mainAdminStackVersionsView', function () {
describe("#observesCategories()", function () {
var mock = {format: Em.K};
- before(function () {
+ beforeEach(function () {
sinon.stub(Em.I18n, 't').returns(mock);
sinon.stub(mock, 'format').returns('label');
sinon.stub(view, 'filterBy').returns([]);
sinon.stub(view, 'filterVersions');
- });
- after(function () {
- Em.I18n.t.restore();
- mock.format.restore();
- view.filterBy.restore();
- view.filterVersions.restore();
- });
- it("", function () {
view.set('categories', [
Em.Object.create({
labelKey: 'labelKey',
@@ -255,20 +247,26 @@ describe('App.mainAdminStackVersionsView', function () {
})
]);
view.observesCategories();
+ });
+ afterEach(function () {
+ Em.I18n.t.restore();
+ mock.format.restore();
+ view.filterBy.restore();
+ view.filterVersions.restore();
+ });
+ it("categories[0].label is updated", function () {
expect(view.get('categories')[0].get('label')).to.equal('label');
+ });
+ it("filterVersions is called once", function () {
expect(view.filterVersions.calledOnce).to.be.true;
});
});
describe("#selectCategory()", function() {
- before(function () {
+ var event;
+ beforeEach(function () {
sinon.stub(view, 'filterVersions');
- });
- after(function () {
- view.filterVersions.restore();
- });
- it("", function() {
- var event = {
+ event = {
context: Em.Object.create({
isSelected: false
})
@@ -280,8 +278,17 @@ describe('App.mainAdminStackVersionsView', function () {
event.context
]);
view.selectCategory(event);
+ });
+ afterEach(function () {
+ view.filterVersions.restore();
+ });
+ it("categories[0].isSelected false", function() {
expect(view.get('categories')[0].get('isSelected')).to.be.false;
+ });
+ it("isSelected is true", function() {
expect(event.context.get('isSelected')).to.be.true;
+ });
+ it("filterVersions is called with correct data", function() {
expect(view.filterVersions.calledWith(event.context)).to.be.true;
});
});
@@ -295,7 +302,7 @@ describe('App.mainAdminStackVersionsView', function () {
view.filterBy.restore();
view.observesCategories.restore();
});
- it("", function() {
+ it("isVisible for repoVersion is updated", function() {
view.set('repoVersions', [Em.Object.create({id: 1})]);
view.filterVersions();
expect(view.get('repoVersions')[0].get('isVisible')).to.be.true;
@@ -348,28 +355,34 @@ describe('App.mainAdminStackVersionsView', function () {
after(function () {
view.poll.restore();
});
- it("", function() {
+ it("poll is called once", function() {
view.willInsertElement();
expect(view.poll.calledOnce).to.be.true;
});
});
describe("#willDestroyElement()", function() {
- var abort = sinon.spy(),
+ var request;
+ beforeEach(function () {
request = {
- abort: abort
+ abort: Em.K
};
- before(function () {
sinon.stub(window, 'clearTimeout', Em.K);
+ sinon.spy(request, 'abort');
view.set('controller.runningCheckRequests', [request, request]);
+ view.willDestroyElement();
});
- after(function () {
+ afterEach(function () {
window.clearTimeout.restore();
+ request.abort.restore();
});
- it("", function() {
- view.willDestroyElement();
+ it("clearTimeout is called once", function() {
expect(window.clearTimeout.calledOnce).to.be.true;
- expect(abort.calledTwice).to.be.true;
+ });
+ it("abort is called twice", function() {
+ expect(request.abort.calledTwice).to.be.true;
+ });
+ it("runningCheckRequests is empty", function() {
expect(view.get('controller.runningCheckRequests')).to.have.length(0);
});
});
@@ -381,7 +394,7 @@ describe('App.mainAdminStackVersionsView', function () {
after(function () {
window.setTimeout.restore();
});
- it("", function() {
+ it("setTimeout is called once", function() {
view.doPolling();
expect(window.setTimeout.calledOnce).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin_test.js b/ambari-web/test/views/main/admin_test.js
index 928480f..53bc39f 100644
--- a/ambari-web/test/views/main/admin_test.js
+++ b/ambari-web/test/views/main/admin_test.js
@@ -86,7 +86,7 @@ describe('App.MainAdminView', function () {
});
describe("#willDestroyElement()", function() {
- it("", function() {
+ it("controller.category is set to null", function() {
view.willDestroyElement();
expect(view.get('controller.category')).to.be.null;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js
index 9ba7bf6..4ddaf50 100644
--- a/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js
+++ b/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js
@@ -82,19 +82,23 @@ describe('App.SelectDefinitionsPopupBodyView', function () {
beforeEach(function () {
sinon.stub(view, 'filterDefs', Em.K);
sinon.stub(view, 'filteredContentObsOnce', Em.K);
- });
- afterEach(function () {
- view.filterDefs.restore();
- view.filteredContentObsOnce.restore();
- });
- it("", function () {
view.set('initialDefs', [
Em.Object.create({filtered: true}),
Em.Object.create({filtered: false})
]);
view.didInsertElement();
+ });
+ afterEach(function () {
+ view.filterDefs.restore();
+ view.filteredContentObsOnce.restore();
+ });
+ it("each availableDefs filtered is updated", function () {
expect(view.get('parentView.availableDefs').mapProperty('filtered')).to.eql([true, true]);
+ });
+ it("parentView.isLoaded is true", function () {
expect(view.get('parentView.isLoaded')).to.be.true;
+ });
+ it("filteredContentObsOnce is called once", function () {
expect(view.filteredContentObsOnce.calledOnce).to.be.true;
});
});
@@ -244,7 +248,7 @@ describe('App.SelectDefinitionsPopupBodyView', function () {
afterEach(function () {
view.filterDefs.restore();
});
- it("", function () {
+ it("is formatted with parentView.availableDefs", function () {
view.set('parentView.availableDefs', [
{selected: true},
{selected: false}
@@ -370,26 +374,38 @@ describe('App.SelectDefinitionsPopupBodyView', function () {
});
describe("#toggleShowSelectedDefs()", function() {
+ var filterComponent;
+ var filterService;
beforeEach(function () {
sinon.stub(view, 'filterDefs', Em.K);
- });
- afterEach(function () {
- view.filterDefs.restore();
- });
-
- it("", function() {
view.set('showOnlySelectedDefs', true);
- var filterComponent = Em.Object.create();
- var filterService = Em.Object.create();
+ filterComponent = Em.Object.create();
+ filterService = Em.Object.create();
view.set('filterComponent', filterComponent);
view.set('filterService', filterService);
-
view.toggleShowSelectedDefs();
+ });
+ afterEach(function () {
+ view.filterDefs.restore();
+ });
+ it("filterComponent.selected is false", function() {
expect(filterComponent.get('selected')).to.be.false;
+ });
+
+ it("filterService.selected is false", function() {
expect(filterService.get('selected')).to.be.false;
+ });
+
+ it("filterComponent is null", function() {
expect(view.get('filterComponent')).to.be.null;
+ });
+
+ it("filterService is null", function() {
expect(view.get('filterService')).to.be.null;
+ });
+
+ it("showOnlySelectedDefs is false", function() {
expect(view.get('showOnlySelectedDefs')).to.be.false;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/charts/heatmap_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/charts/heatmap_test.js b/ambari-web/test/views/main/charts/heatmap_test.js
index 60df2eb..c3ad695 100644
--- a/ambari-web/test/views/main/charts/heatmap_test.js
+++ b/ambari-web/test/views/main/charts/heatmap_test.js
@@ -41,7 +41,7 @@ describe('App.MainChartsHeatmapView', function () {
afterEach(function () {
view.get('controller').loadPageData.restore();
});
- it("", function () {
+ it("loadPageData is called once", function () {
view.didInsertElement();
expect(view.get('controller').loadPageData.calledOnce).to.be.true;
});
@@ -54,7 +54,7 @@ describe('App.MainChartsHeatmapView', function () {
afterEach(function () {
view.get('controller').clearActiveWidgetLayout.restore();
});
- it("", function () {
+ it("clearActiveWidgetLayout is called once", function () {
view.willDestroyElement();
expect(view.get('controller').clearActiveWidgetLayout.calledOnce).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/dashboard/config_history_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/config_history_view_test.js b/ambari-web/test/views/main/dashboard/config_history_view_test.js
index 76ad4bd..4ac8401 100644
--- a/ambari-web/test/views/main/dashboard/config_history_view_test.js
+++ b/ambari-web/test/views/main/dashboard/config_history_view_test.js
@@ -46,7 +46,7 @@ describe('App.MainConfigHistoryView', function() {
view.removeObserver('controller.resetStartIndex', view, 'resetStartIndex');
describe("#filteredContentInfo", function () {
- it("", function () {
+ it("is formatted with filteredCount and totalCount", function () {
view.set('filteredCount', 1);
view.set('totalCount', 2);
view.propertyDidChange('filteredContentInfo');
@@ -226,18 +226,32 @@ describe('App.MainConfigHistoryView', function() {
});
describe('#didInsertElement()', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.stub(view, 'addObserver', Em.K);
sinon.spy(view.get('controller'), 'doPolling');
-
view.didInsertElement();
+ });
+
+ afterEach(function () {
+ view.addObserver.restore();
+ view.get('controller').doPolling.restore();
+ });
+
+ it('addObserver is called twice', function() {
expect(view.addObserver.calledTwice).to.be.true;
+ });
+
+ it('isInitialRendering is true', function() {
expect(view.get('isInitialRendering')).to.be.true;
+ });
+
+ it('controller.isPolling is true', function() {
expect(view.get('controller.isPolling')).to.be.true;
- expect(view.get('controller').doPolling.calledOnce).to.be.true;
+ });
- view.addObserver.restore();
- view.get('controller').doPolling.restore();
+ it('controller.doPolling is true', function() {
+ expect(view.get('controller').doPolling.calledOnce).to.be.true;
});
});
@@ -271,43 +285,50 @@ describe('App.MainConfigHistoryView', function() {
});
describe('#willDestroyElement()', function() {
- it('', function() {
+ it('controller.isPolling is false', function() {
view.willDestroyElement();
expect(view.get('controller.isPolling')).to.be.false;
});
});
describe('#refresh()', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.spy(view.get('controller'), 'load');
view.refresh();
+ });
+
+ afterEach(function () {
+ view.get('controller').load.restore();
+ });
+
+ it('filteringComplete is false', function() {
expect(view.get('filteringComplete')).to.be.false;
+ });
+
+ it('controller.load is called once', function() {
expect(view.get('controller').load.calledOnce).to.be.true;
- view.get('controller').load.restore();
});
});
describe("#refreshDone()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(view, 'propertyDidChange', Em.K);
- });
- after(function () {
- view.propertyDidChange.restore();
- });
- it("", function () {
view.set('filteringComplete', false);
view.set('controller.resetStartIndex', true);
view.refreshDone();
+ });
+ afterEach(function () {
+ view.propertyDidChange.restore();
+ });
+ it("filteringComplete is true", function () {
expect(view.get('filteringComplete')).to.be.true;
+ });
+ it("controller.resetStartIndex is false", function () {
expect(view.get('controller.resetStartIndex')).to.be.false;
});
});
- describe("#colPropAssoc", function () {
- it("", function () {
- view.set('controller.colPropAssoc', [1]);
- view.propertyDidChange('colPropAssoc');
- expect(view.get('colPropAssoc')).to.eql([1]);
- });
- });
+ App.TestAliases.testAsComputedAlias(view, 'colPropAssoc', 'controller.colPropAssoc', 'array');
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index 0625474..36a1a42 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -93,15 +93,9 @@ describe('App.DashboardWidgetView', function () {
});
describe("#deleteWidgetComplete()", function () {
- before(function () {
+ beforeEach(function () {
sinon.spy(dashboardWidgetView.get('parentView'), 'postUserPref');
sinon.spy(dashboardWidgetView.get('parentView'), 'translateToReal');
- });
- after(function () {
- dashboardWidgetView.get('parentView').postUserPref.restore();
- dashboardWidgetView.get('parentView').translateToReal.restore();
- });
- it("", function () {
dashboardWidgetView.set('parentView.currentPrefObject', {
dashboardVersion: 'new',
visible: ['1', '2'],
@@ -110,12 +104,20 @@ describe('App.DashboardWidgetView', function () {
});
dashboardWidgetView.set('parentView.persistKey', 'key');
dashboardWidgetView.deleteWidgetComplete();
+ });
+ afterEach(function () {
+ dashboardWidgetView.get('parentView').postUserPref.restore();
+ dashboardWidgetView.get('parentView').translateToReal.restore();
+ });
+ it("postUserPref is called with correct data", function () {
expect(dashboardWidgetView.get('parentView').postUserPref.calledWith('key', {
dashboardVersion: 'new',
visible: ['2'],
hidden: ['1'],
threshold: 'threshold'
}));
+ });
+ it("translateToReal is called with valid data", function () {
expect(dashboardWidgetView.get('parentView').translateToReal.calledWith({
dashboardVersion: 'new',
visible: ['2'],
@@ -231,7 +233,7 @@ describe('App.DashboardWidgetView', function () {
describe("#widgetConfig", function() {
var widget = dashboardWidgetView.get('widgetConfig').create();
describe("#hintInfo", function() {
- it("", function() {
+ it("is formatted with maxValue", function() {
widget.set('maxValue', 1);
widget.propertyDidChange('hintInfo');
expect(widget.get('hintInfo')).to.equal(Em.I18n.t('dashboard.widgets.hintInfo.common').format(1));
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/dashboard/widgets_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js
index 558dbe3..311bf21 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -140,24 +140,32 @@ describe('App.MainDashboardWidgetsView', function () {
});
describe("#didInsertElement()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(view, 'setWidgetsDataModel', Em.K);
sinon.stub(view, 'setInitPrefObject', Em.K);
sinon.stub(view, 'setOnLoadVisibleWidgets', Em.K);
sinon.stub(Em.run, 'next', Em.K);
+ view.didInsertElement();
});
- after(function () {
+ afterEach(function () {
view.setWidgetsDataModel.restore();
view.setInitPrefObject.restore();
view.setOnLoadVisibleWidgets.restore();
Em.run.next.restore();
});
- it("", function () {
- view.didInsertElement();
+ it("setWidgetsDataModel is called once", function () {
expect(view.setWidgetsDataModel.calledOnce).to.be.true;
+ });
+ it("setInitPrefObject is called once", function () {
expect(view.setInitPrefObject.calledOnce).to.be.true;
+ });
+ it("setOnLoadVisibleWidgets is called once", function () {
expect(view.setOnLoadVisibleWidgets.calledOnce).to.be.true;
+ });
+ it("makeSortable is called in the next loop", function () {
expect(Em.run.next.calledWith(view, 'makeSortable')).to.be.true;
+ });
+ it("isDataLoaded is true", function () {
expect(view.get('isDataLoaded')).to.be.true
});
});
@@ -239,21 +247,10 @@ describe('App.MainDashboardWidgetsView', function () {
beforeEach(function () {
sinon.stub(view, 'postUserPref');
sinon.stub(view, 'translateToReal');
- });
- afterEach(function () {
- view.postUserPref.restore();
- view.translateToReal.restore();
- });
- beforeEach(function () {
sinon.stub(App.router, 'get', function (k) {
if ('loginName' === k) return 'tdk';
return Em.get(App.router, k);
});
- });
- afterEach(function () {
- App.router.get.restore();
- });
- it("", function () {
plusButtonFilterView.set('hiddenWidgets', [
Em.Object.create({
checked: true,
@@ -274,7 +271,16 @@ describe('App.MainDashboardWidgetsView', function () {
}));
view.set('persistKey', 'key');
plusButtonFilterView.applyFilterComplete();
+ });
+ afterEach(function () {
+ view.postUserPref.restore();
+ view.translateToReal.restore();
+ App.router.get.restore();
+ });
+ it("postUserPref is called once", function () {
expect(view.postUserPref.calledOnce).to.be.true;
+ });
+ it("translateToReal is called with correct data", function () {
expect(view.translateToReal.getCall(0).args[0]).to.eql(Em.Object.create({
dashboardVersion: 'new',
visible: [1],
@@ -283,6 +289,8 @@ describe('App.MainDashboardWidgetsView', function () {
],
threshold: 'threshold'
}));
+ });
+ it("1 hidden widget", function () {
expect(plusButtonFilterView.get('hiddenWidgets.length')).to.equal(1);
});
});
@@ -352,16 +360,22 @@ describe('App.MainDashboardWidgetsView', function () {
});
describe("#removeWidget()", function () {
- it("", function () {
- var widget = {};
- var value = {
+ var widget;
+ var value;
+ beforeEach(function () {
+ widget = {};
+ value = {
visible: [widget],
hidden: [
[widget]
]
};
value = view.removeWidget(value, widget);
+ });
+ it("value.visible is empty", function () {
expect(value.visible).to.be.empty;
+ });
+ it("value.hidden is empty", function () {
expect(value.hidden).to.be.empty;
});
});
@@ -404,7 +418,7 @@ describe('App.MainDashboardWidgetsView', function () {
after(function () {
App.get.restore();
});
- it("", function () {
+ it("depends on router.loginName", function () {
view.propertyDidChange('persistKey');
expect(view.get('persistKey')).to.equal('user-pref-user-dashboard');
});
@@ -445,7 +459,7 @@ describe('App.MainDashboardWidgetsView', function () {
after(function () {
App.showConfirmationPopup.restore();
});
- it("", function () {
+ it("showConfirmationPopup is called once", function () {
view.resetAllWidgets();
expect(App.showConfirmationPopup.calledOnce).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/host/stack_versions_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/stack_versions_view_test.js b/ambari-web/test/views/main/host/stack_versions_view_test.js
index 8023cc9..7bbd371 100644
--- a/ambari-web/test/views/main/host/stack_versions_view_test.js
+++ b/ambari-web/test/views/main/host/stack_versions_view_test.js
@@ -41,7 +41,7 @@ describe('App.MainHostStackVersionsView', function() {
App.router.get.restore();
view.filter.restore();
});
- it("", function () {
+ it("host.id is updated", function () {
view.propertyDidChange('host');
expect(view.get('host.id')).to.equal(1);
});
@@ -60,7 +60,7 @@ describe('App.MainHostStackVersionsView', function() {
view.get.restore();
view.filter.restore();
});
- it("", function () {
+ it("content.id is updated", function () {
view.propertyDidChange('content');
expect(view.get('content')).to.eql([Em.Object.create({
id: 1
@@ -69,7 +69,7 @@ describe('App.MainHostStackVersionsView', function() {
});
describe("#filteredContentInfo", function () {
- it("", function () {
+ it("formatted with filteredCount and totalCount", function () {
view.set('filteredCount', 1);
view.set('totalCount', 2);
view.propertyDidChange('filteredContentInfo');
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/wizard/step4_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step4_view_test.js b/ambari-web/test/views/wizard/step4_view_test.js
index 94f9830..11d11dc 100644
--- a/ambari-web/test/views/wizard/step4_view_test.js
+++ b/ambari-web/test/views/wizard/step4_view_test.js
@@ -34,7 +34,7 @@ describe('App.WizardStep4View', function () {
afterEach(function () {
App.get('router').set.restore();
});
- it('', function () {
+ it('router.transitionInProgress is set to false', function () {
view.didInsertElement();
expect(App.get('router').set.calledWith('transitionInProgress', false)).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/wizard/step6_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step6_view_test.js b/ambari-web/test/views/wizard/step6_view_test.js
index 9beca51..b5d2f43 100644
--- a/ambari-web/test/views/wizard/step6_view_test.js
+++ b/ambari-web/test/views/wizard/step6_view_test.js
@@ -111,23 +111,32 @@ describe('App.WizardStep6View', function() {
});
describe("#checkboxClick()", function() {
+ var e;
beforeEach(function() {
sinon.stub(view.get('controller'), 'checkCallback', Em.K);
sinon.stub(view.get('controller'), 'callValidation', Em.K);
+ e = {
+ context: {
+ checked: true,
+ component: 'c1'
+ }
+ };
+ view.checkboxClick(e);
});
afterEach(function() {
view.get('controller').checkCallback.restore();
view.get('controller').callValidation.restore();
});
- it("", function() {
- var e = {context: {
- checked: true,
- component: 'c1'
- }};
- view.checkboxClick(e);
+ it("checked is false", function() {
expect(e.context.checked).to.be.false;
+ });
+
+ it("checkCallback is called with correct data", function() {
expect(view.get('controller').checkCallback.calledWith('c1')).to.be.true;
+ });
+
+ it("callValidation is called once", function() {
expect(view.get('controller').callValidation.calledOnce).to.be.true;
});
});
[3/3] ambari git commit: AMBARI-14356.
hostWarningPopupBody_view_test.js unit test failing intermittently
(onechiporenko)
Posted by on...@apache.org.
AMBARI-14356. hostWarningPopupBody_view_test.js unit test failing intermittently (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1901b395
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1901b395
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1901b395
Branch: refs/heads/trunk
Commit: 1901b395c274a0ad3833b282164e54a7a1e74eb3
Parents: 17f7b71
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Dec 17 16:05:01 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Fri Dec 18 11:36:17 2015 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
ambari-web/app/utils/ember_reopen.js | 10 +
.../global/update_controller_test.js | 4 +-
.../global/user_settings_controller_test.js | 76 +---
ambari-web/test/controllers/installer_test.js | 29 +-
.../nameNode/step2_controller_test.js | 42 +-
.../nameNode/step3_controller_test.js | 4 +
.../progress_popup_controller_test.js | 4 +
.../admin/kerberos/step6_controller_test.js | 14 +-
.../controllers/main/admin/kerberos_test.js | 6 +-
.../admin/stack_and_upgrade_controller_test.js | 391 ++++++++++---------
.../add_alert_definition_controller_test.js | 4 +-
.../alerts/alert_instances_controller_test.js | 10 +-
.../definitions_configs_controller_test.js | 24 +-
.../heatmap_metrics/heatmap_metric_test.js | 2 +-
.../dashboard/config_history_controller_test.js | 46 ++-
.../main/host/add_controller_test.js | 54 ++-
.../test/controllers/main/host/details_test.js | 158 ++++----
.../main/host/host_alerts_controller_test.js | 3 +-
.../main/service/info/summary_test.js | 18 +-
.../test/controllers/main/service/item_test.js | 21 +-
.../manage_config_groups_controller_test.js | 200 +++++-----
.../service/reassign/step2_controller_test.js | 4 +-
.../service/reassign/step3_controller_test.js | 10 +-
.../service/reassign/step4_controller_test.js | 118 ++++--
.../service/reassign/step6_controller_test.js | 2 +-
.../widgets/create/step1_controller_test.js | 16 +-
.../widgets/create/step2_controller_test.js | 43 +-
.../widgets/create/step3_controller_test.js | 53 ++-
.../test/controllers/wizard/step2_test.js | 6 +-
.../test/controllers/wizard/step3_test.js | 76 +---
.../test/controllers/wizard/step6_test.js | 15 +-
.../test/controllers/wizard/step7_test.js | 18 +-
.../test/controllers/wizard/step9_test.js | 10 +-
.../common/table_server_view_mixin_test.js | 8 +-
.../test/mixins/common/widget_mixin_test.js | 201 ++++++----
ambari-web/test/models/host_component_test.js | 55 ++-
ambari-web/test/models/host_test.js | 19 +-
ambari-web/test/router_test.js | 6 +-
ambari-web/test/utils/helper_test.js | 12 +-
ambari-web/test/utils/load_timer_test.js | 4 +-
.../test/views/common/chart/linear_time_test.js | 18 +-
.../common/configs/config_history_flow_test.js | 76 +++-
.../widgets/time_interval_spinner_view_test.js | 2 +-
.../test/views/common/progress_bar_view_test.js | 2 +-
.../test/views/common/quick_link_view_test.js | 279 ++++++-------
.../nameNode/step3_view_test.js | 8 +-
.../nameNode/step4_view_test.js | 2 +-
.../nameNode/step6_view_test.js | 2 +-
.../nameNode/step8_view_test.js | 2 +-
.../highAvailability/progress_view_test.js | 4 +-
.../failed_hosts_modal_view_test.js | 4 +-
.../admin/stack_upgrade/services_view_test.js | 2 +-
.../stack_upgrade/upgrade_group_view_test.js | 19 +-
.../stack_upgrade/upgrade_task_view_test.js | 33 +-
.../stack_upgrade/upgrade_wizard_view_test.js | 65 +--
.../admin/stack_upgrade/version_view_test.js | 67 ++--
ambari-web/test/views/main/admin_test.js | 2 +-
.../select_definitions_popup_body_view_test.js | 48 ++-
.../test/views/main/charts/heatmap_test.js | 4 +-
.../main/dashboard/config_history_view_test.js | 65 +--
.../test/views/main/dashboard/widget_test.js | 18 +-
.../test/views/main/dashboard/widgets_test.js | 54 ++-
.../views/main/host/stack_versions_view_test.js | 6 +-
ambari-web/test/views/wizard/step4_view_test.js | 2 +-
ambari-web/test/views/wizard/step6_view_test.js | 21 +-
66 files changed, 1453 insertions(+), 1149 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index c44eda8..d13767f 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -46,6 +46,7 @@ var files = [
'test/controllers/global/update_controller_test',
'test/controllers/global/configuration_controller_test',
'test/controllers/global/wizard_watcher_controller_test',
+ 'test/controllers/global/user_settings_controller_test',
'test/controllers/main/alert_definitions_controller_test',
'test/controllers/main/alerts/alert_definitions_actions_controller_test',
'test/controllers/main/alerts/definitions_configs_controller_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/app/utils/ember_reopen.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_reopen.js b/ambari-web/app/utils/ember_reopen.js
index 29d14c8..0eefb97 100644
--- a/ambari-web/app/utils/ember_reopen.js
+++ b/ambari-web/app/utils/ember_reopen.js
@@ -128,6 +128,16 @@ Ember.sum = function (a, b) {
};
/**
+ * Execute passed callback
+ *
+ * @param {Function} callback
+ * @returns {*}
+ */
+Ember.clb = function (callback) {
+ return callback();
+};
+
+/**
*
*/
Ember.RadioButton = Ember.Checkbox.extend({
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 482e58c..807d99d 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -255,7 +255,7 @@ describe('App.UpdateController', function () {
App.get.restore();
controller.computeParameters.restore();
});
- it("", function () {
+ it("valid params are added", function () {
expect(controller.addParamsToHostsUrl([], [], 'url')).to.equal('mock/clusters/mockurl¶ms¶ms');
});
});
@@ -292,7 +292,7 @@ describe('App.UpdateController', function () {
afterEach(function () {
App.hostsMapper.setMetrics.restore();
});
- it("", function () {
+ it("setMetrics called with valid arguments", function () {
controller.loadHostsMetricSuccessCallback({});
expect(App.hostsMapper.setMetrics.calledWith({})).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/global/user_settings_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/user_settings_controller_test.js b/ambari-web/test/controllers/global/user_settings_controller_test.js
index 13a73df..7c49645 100644
--- a/ambari-web/test/controllers/global/user_settings_controller_test.js
+++ b/ambari-web/test/controllers/global/user_settings_controller_test.js
@@ -22,81 +22,21 @@ var userSettingsController;
describe('App.UserSettingsController', function () {
beforeEach(function () {
+ sinon.stub(App.ajax, 'send', function () {
+ return {complete: Em.K}
+ });
userSettingsController = App.UserSettingsController.create();
});
+ afterEach(function () {
+ App.ajax.send.restore();
+ userSettingsController.destroy();
+ });
+
describe('#userSettingsKeys', function () {
it('should not be empty', function () {
expect(Object.keys(userSettingsController.get('userSettingsKeys'))).to.have.length.gt(0);
});
});
- describe('#showSettingsPopup', function() {
- var dataToShowRes = {};
-
- beforeEach(function () {
- sinon.stub(App.ModalPopup, 'show', function(dataToShow){
- dataToShowRes = dataToShow;
- });
- sinon.stub(App, 'isAuthorized').returns(true);
- var emulatorClass = function() {};
- emulatorClass.prototype.done = function(func) {
- if (func) {
- func();
- }
- };
- var emulator = new emulatorClass();
- sinon.stub(userSettingsController, 'dataLoading').returns(emulator);
- });
- afterEach(function () {
- App.isAuthorized.restore();
- App.ModalPopup.show.restore();
- userSettingsController.dataLoading.restore();
- });
- it ('Should show settings popup', function() {
- userSettingsController.showSettingsPopup();
- dataToShowRes = JSON.parse(JSON.stringify(dataToShowRes));
- expect(dataToShowRes).to.eql({
- "header": "User Settings",
- "primary": "Save"
- });
- });
- });
-
- describe('#getUserPrefErrorCallback', function() {
- it ('Should set currentPrefObject', function() {
- applicationController.getUserPrefErrorCallback({status: 404}, {}, {});
- expect(applicationController.get('currentPrefObject')).to.be.true;
- });
- });
-
- describe('#getUserPrefSuccessCallback', function() {
- it ('Should set currentPrefObject', function() {
- applicationController.getUserPrefSuccessCallback({status: 200}, {}, {});
- expect(applicationController.get('currentPrefObject')).to.be.eql({status: 200});
- });
- });
-
- describe('#updateUserPrefWithDefaultValues', function () {
-
- beforeEach(function () {
- sinon.stub(userSettingsController, 'postUserPref', Em.K);
- });
-
- afterEach(function () {
- userSettingsController.postUserPref.restore();
- });
-
- it('should update user pref with default values', function () {
- userSettingsController.updateUserPrefWithDefaultValues(null, true);
- expect(userSettingsController.postUserPref.called).to.be.false;
- });
-
- it('should not update user pref with default values', function () {
- userSettingsController.updateUserPrefWithDefaultValues(null, false);
- expect(userSettingsController.postUserPref.called).to.be.true;
- });
-
- });
-
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 1f370d3..06d4ca7 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -26,6 +26,20 @@ describe('App.InstallerController', function () {
var installerController = App.InstallerController.create();
+ after(function () {
+ installerController.destroy();
+ });
+
+ beforeEach(function () {
+ sinon.stub(App.ajax, 'send', function () {
+ return {complete: Em.K};
+ });
+ });
+
+ afterEach(function () {
+ App.ajax.send.restore();
+ });
+
describe('#init', function () {
var c;
beforeEach(function () {
@@ -80,14 +94,7 @@ describe('App.InstallerController', function () {
});
describe('#checkRepoURL', function() {
- beforeEach(function () {
- sinon.stub(App.ajax, 'send', function(data){
- return null;
- });
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
+
it ('Should reload installed stacks', function() {
var stacks = Em.A([
Em.Object.create({
@@ -113,7 +120,7 @@ describe('App.InstallerController', function () {
})
])
})
- ])
+ ])
})
]);
var wizard = Em.Object.create({
@@ -185,7 +192,7 @@ describe('App.InstallerController', function () {
})
])
})
- ])
+ ])
})
]);
var resolve = false;
@@ -267,7 +274,7 @@ describe('App.InstallerController', function () {
})
])
})
- ])
+ ])
})
]);
var resolve = false;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js
index 731094f..570f45a 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js
@@ -18,45 +18,21 @@
var App = require('app');
+function O (fl) {
+ return Em.Object.create({
+ isInstalled: fl
+ })
+}
+
describe('App.HighAvailabilityWizardStep2Controller', function () {
var controller = App.HighAvailabilityWizardStep2Controller.create();
describe('#sortMasterComponents', function () {
it('should sort installed masters first', function() {
- expect(controller.sortMasterComponents([
- Em.Object.create({
- isInstalled: true
- }),
- Em.Object.create({
- isInstalled: false
- }),
- Em.Object.create({
- isInstalled: true
- }),
- Em.Object.create({
- isInstalled: false
- }),
- Em.Object.create({
- isInstalled: true
- })
- ])).to.eql([
- Em.Object.create({
- isInstalled: true
- }),
- Em.Object.create({
- isInstalled: true
- }),
- Em.Object.create({
- isInstalled: true
- }),
- Em.Object.create({
- isInstalled: false
- }),
- Em.Object.create({
- isInstalled: false
- })
- ]);
+ var init = [O(true), O(false), O(true), O(false), O(true)];
+ var sorted = [O(true), O(true), O(true), O(false), O(false)];
+ expect(controller.sortMasterComponents(init)).to.eql(sorted);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 7fbb4ca..aff4413 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
@@ -71,6 +71,10 @@ describe('App.HighAvailabilityWizardStep3Controller', function() {
controller.set('serverConfigData', serverConfigData);
});
+ afterEach(function () {
+ controller.destroy();
+ });
+
describe('#removeConfigs', function() {
var tests = [
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
index 95512e9..bd8deb3 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
@@ -28,6 +28,10 @@ describe('App.HighAvailabilityProgressPopupController', function () {
controller = App.HighAvailabilityProgressPopupController.create();
});
+ after(function () {
+ controller.destroy();
+ });
+
describe('#startTaskPolling', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/admin/kerberos/step6_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step6_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step6_controller_test.js
index 053f70e..780f896 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step6_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step6_controller_test.js
@@ -19,8 +19,15 @@
var App = require('app');
describe('App.KerberosWizardStep6Controller', function() {
+
describe('#checkComponentsRemoval', function() {
+ afterEach(function () {
+ Em.tryInvoke(App.get, 'restore');
+ Em.tryInvoke(App.Service.find, 'restore');
+ Em.tryInvoke(App.HostComponent.find, 'restore');
+ });
+
var tests = [
{ yarnInstalled: true, doesATSSupportKerberos: false, commands: ['stopServices', 'deleteATS'], ATSInstalled: true},
{ yarnInstalled: false, doesATSSupportKerberos: true, commands: ['stopServices'], ATSInstalled: true},
@@ -33,12 +40,9 @@ describe('App.KerberosWizardStep6Controller', function() {
it('YARN installed: {0}, ATS supported: {1} list of commands should be {2}'.format(test.yarnInstalled, test.doesATSSupportKerberos, test.commands.toString()), function () {
var controller = App.KerberosWizardStep6Controller.create({ commands: ['stopServices'] });
sinon.stub(App, 'get').withArgs('doesATSSupportKerberos').returns(test.doesATSSupportKerberos);
- sinon.stub(App.Service, 'find').returns(test.yarnInstalled ? [Em.Object.create({ serviceName: 'YARN'})] : []);
- sinon.stub(App.HostComponent, 'find').returns(test.ATSInstalled ? [Em.Object.create({ componentName: 'APP_TIMELINE_SERVER'})] : []);
+ sinon.stub(App.Service, 'find').returns(test.yarnInstalled ? [Em.Object.create({serviceName: 'YARN'})] : []);
+ sinon.stub(App.HostComponent, 'find').returns(test.ATSInstalled ? [Em.Object.create({componentName: 'APP_TIMELINE_SERVER'})] : []);
controller.checkComponentsRemoval();
- App.get.restore();
- App.Service.find.restore();
- App.HostComponent.find.restore();
expect(controller.get('commands').toArray()).to.eql(test.commands);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/admin/kerberos_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos_test.js b/ambari-web/test/controllers/main/admin/kerberos_test.js
index 4b58069..e05dfdb 100644
--- a/ambari-web/test/controllers/main/admin/kerberos_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos_test.js
@@ -39,7 +39,7 @@ describe('App.MainAdminKerberosController', function() {
Em.Object.create({ name: 'prop2', isEditable: true, serviceName: 'KERBEROS'}),
Em.Object.create({ name: 'prop3', isEditable: true, serviceName: 'HDFS'}),
Em.Object.create({ name: 'prop4', isEditable: true, serviceName: 'Cluster'}),
- Em.Object.create({ name: 'prop5', isEditable: true, serviceName: 'SERVICE1'}),
+ Em.Object.create({ name: 'prop5', isEditable: true, serviceName: 'SERVICE1'})
]);
});
@@ -201,6 +201,7 @@ describe('App.MainAdminKerberosController', function() {
App.ajax.send.restore();
mock.callback.restore();
controller.getSecurityType.restore();
+ Em.tryInvoke(App.get, 'restore');
});
[
@@ -231,7 +232,6 @@ describe('App.MainAdminKerberosController', function() {
controller.set('securityEnabled', test.securityEnabled);
controller.set('kdc_type', test.kdc_type);
controller.getKDCSessionState(mock.callback);
- App.get.restore();
if (test.result) {
expect(mock.callback.calledOnce).to.be.false;
expect(App.ajax.send.calledOnce).to.be.true;
@@ -255,6 +255,7 @@ describe('App.MainAdminKerberosController', function() {
afterEach(function () {
App.ajax.send.restore();
mock.callback.restore();
+ Em.tryInvoke(App.get, 'restore');
});
[
@@ -285,7 +286,6 @@ describe('App.MainAdminKerberosController', function() {
controller.set('securityEnabled', test.securityEnabled);
controller.set('kdc_type', test.kdc_type);
controller.getSecurityType(mock.callback);
- App.get.restore();
if (test.result) {
expect(mock.callback.calledOnce).to.be.false;
expect(App.ajax.send.calledOnce).to.be.true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 630d0b2..392f899 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
@@ -28,16 +28,25 @@ describe('App.MainAdminStackAndUpgradeController', function() {
setDBProperty: Em.K
});
+ before(function () {
+ sinon.stub(App.router, 'get').withArgs('clusterController.isLoaded').returns(false);
+ });
+
+ after(function () {
+ App.router.get.restore();
+ controller.destroy();
+ });
+
describe("#realRepoUrl", function() {
before(function () {
this.mock = sinon.stub(App, 'get');
+ this.mock.withArgs('apiPrefix').returns('apiPrefix')
+ .withArgs('stackVersionURL').returns('stackVersionURL');
});
after(function () {
this.mock.restore();
});
- it("", function() {
- this.mock.withArgs('apiPrefix').returns('apiPrefix');
- this.mock.withArgs('stackVersionURL').returns('stackVersionURL');
+ it("should be valid", function() {
controller.propertyDidChange('realRepoUrl');
expect(controller.get('realRepoUrl')).to.equal('apiPrefixstackVersionURL/compatible_repository_versions?fields=*,operating_systems/*,operating_systems/repositories/*');
});
@@ -46,13 +55,13 @@ describe('App.MainAdminStackAndUpgradeController', function() {
describe("#realStackUrl", function() {
before(function () {
this.mock = sinon.stub(App, 'get');
+ this.mock.withArgs('apiPrefix').returns('apiPrefix')
+ .withArgs('clusterName').returns('clusterName');
});
after(function () {
this.mock.restore();
});
- it("", function() {
- this.mock.withArgs('apiPrefix').returns('apiPrefix');
- this.mock.withArgs('clusterName').returns('clusterName');
+ it("should be valid", function() {
controller.propertyDidChange('realStackUrl');
expect(controller.get('realStackUrl')).to.equal('apiPrefix/clusters/clusterName/stack_versions?fields=*,repository_versions/*,repository_versions/operating_systems/repositories/*');
});
@@ -61,13 +70,13 @@ describe('App.MainAdminStackAndUpgradeController', function() {
describe("#realUpdateUrl", function() {
before(function () {
this.mock = sinon.stub(App, 'get');
+ this.mock.withArgs('apiPrefix').returns('apiPrefix')
+ .withArgs('clusterName').returns('clusterName');
});
after(function () {
this.mock.restore();
});
- it("", function() {
- this.mock.withArgs('apiPrefix').returns('apiPrefix');
- this.mock.withArgs('clusterName').returns('clusterName');
+ it("realUpdateUrl is valid", function() {
controller.propertyDidChange('realUpdateUrl');
expect(controller.get('realUpdateUrl')).to.equal('apiPrefix/clusters/clusterName/stack_versions?fields=ClusterStackVersions/*');
});
@@ -87,15 +96,15 @@ describe('App.MainAdminStackAndUpgradeController', function() {
});
describe("#load()", function() {
- before(function(){
+ beforeEach(function(){
sinon.stub(controller, 'loadUpgradeData').returns({
- done: function(callback) {callback();}
+ done: Em.clb
});
sinon.stub(controller, 'loadStackVersionsToModel').returns({
- done: function(callback) {callback();}
+ done: Em.clb
});
sinon.stub(controller, 'loadRepoVersionsToModel').returns({
- done: function(callback) {callback();}
+ done: Em.clb
});
sinon.stub(App.StackVersion, 'find').returns([Em.Object.create({
state: 'CURRENT',
@@ -104,18 +113,24 @@ describe('App.MainAdminStackAndUpgradeController', function() {
displayName: 'HDP-2.2'
}
})]);
+ controller.load();
});
- after(function(){
+ afterEach(function(){
controller.loadUpgradeData.restore();
controller.loadStackVersionsToModel.restore();
controller.loadRepoVersionsToModel.restore();
App.StackVersion.find.restore();
});
- it("", function() {
- controller.load();
+ it("loadUpgradeData called with valid arguments", function() {
expect(controller.loadUpgradeData.calledWith(true)).to.be.true;
+ });
+ it('loadStackVersionsToModel called with valid arguments', function () {
expect(controller.loadStackVersionsToModel.calledWith(true)).to.be.true;
+ });
+ it('loadRepoVersionsToModel called once', function () {
expect(controller.loadRepoVersionsToModel.calledOnce).to.be.true;
+ });
+ it('currentVersion is corrent', function () {
expect(controller.get('currentVersion')).to.eql({
"repository_version": "2.2",
"repository_name": "HDP-2.2"
@@ -524,11 +539,12 @@ describe('App.MainAdminStackAndUpgradeController', function() {
value: '2.2',
label: 'HDP-2.2'
});
- expect(App.ajax.send.getCall(0).args[0].data).to.eql({"value": '2.2', "label": 'HDP-2.2'});
- expect(App.ajax.send.getCall(0).args[0].name).to.eql('admin.upgrade.start');
- expect(App.ajax.send.getCall(0).args[0].sender).to.eql(controller);
- expect(App.ajax.send.getCall(0).args[0].success).to.eql('upgradeSuccessCallback');
- expect(App.ajax.send.getCall(0).args[0].callback).to.be.called;
+ var callArgs = App.ajax.send.getCall(0).args[0];
+ expect(callArgs.data).to.eql({"value": '2.2', "label": 'HDP-2.2'});
+ expect(callArgs.name).to.eql('admin.upgrade.start');
+ expect(callArgs.sender).to.eql(controller);
+ expect(callArgs.success).to.eql('upgradeSuccessCallback');
+ expect(callArgs.callback).to.be.called;
expect(controller.setDBProperty.calledWith('currentVersion', {
repository_version: '2.2'
})).to.be.true;
@@ -580,105 +596,112 @@ describe('App.MainAdminStackAndUpgradeController', function() {
controller.updateUpgradeData({});
expect(controller.initUpgradeData.calledWith({})).to.be.true;
});
- it("update loaded data", function() {
- var oldData = Em.Object.create({
- upgradeGroups: [
- Em.Object.create({
- group_id: 1,
- upgradeItems: [
- Em.Object.create({
- stage_id: 1
- })
- ]
- }),
- Em.Object.create({
- group_id: 2,
- upgradeItems: [
- Em.Object.create({
- stage_id: 2
- }),
- Em.Object.create({
- stage_id: 3
- })
- ]
- })
- ]
- });
- var newData = {
- Upgrade: {
- request_id: 1
- },
- upgrade_groups: [
- {
- UpgradeGroup: {
+
+ describe('upgradeData exists', function () {
+
+ var groups;
+
+ beforeEach(function() {
+ var oldData = Em.Object.create({
+ upgradeGroups: [
+ Em.Object.create({
group_id: 1,
- status: 'COMPLETED',
- progress_percent: 100,
- completed_task_count: 3
- },
- upgrade_items: [
- {
- UpgradeItem: {
- stage_id: 1,
- status: 'COMPLETED',
- progress_percent: 100
- }
- }
- ]
- },
- {
- UpgradeGroup: {
+ upgradeItems: [
+ Em.Object.create({
+ stage_id: 1
+ })
+ ]
+ }),
+ Em.Object.create({
group_id: 2,
- status: 'ABORTED',
- progress_percent: 50,
- completed_task_count: 1
- },
- upgrade_items: [
- {
- UpgradeItem: {
- stage_id: 2,
- status: 'ABORTED',
- progress_percent: 99
+ upgradeItems: [
+ Em.Object.create({
+ stage_id: 2
+ }),
+ Em.Object.create({
+ stage_id: 3
+ })
+ ]
+ })
+ ]
+ });
+ var newData = {
+ Upgrade: {
+ request_id: 1
+ },
+ upgrade_groups: [
+ {
+ UpgradeGroup: {
+ group_id: 1,
+ status: 'COMPLETED',
+ progress_percent: 100,
+ completed_task_count: 3
+ },
+ upgrade_items: [
+ {
+ UpgradeItem: {
+ stage_id: 1,
+ status: 'COMPLETED',
+ progress_percent: 100
+ }
}
+ ]
+ },
+ {
+ UpgradeGroup: {
+ group_id: 2,
+ status: 'ABORTED',
+ progress_percent: 50,
+ completed_task_count: 1
},
- {
- UpgradeItem: {
- stage_id: 3,
- status: 'PENDING',
- progress_percent: 0
+ upgrade_items: [
+ {
+ UpgradeItem: {
+ stage_id: 2,
+ status: 'ABORTED',
+ progress_percent: 99
+ }
+ },
+ {
+ UpgradeItem: {
+ stage_id: 3,
+ status: 'PENDING',
+ progress_percent: 0
+ }
}
- }
- ]
- }
- ]
- };
- controller.set('upgradeData', oldData);
- controller.updateUpgradeData(newData);
- expect(controller.get('upgradeData.upgradeGroups')[0].get('status')).to.equal('COMPLETED');
- expect(controller.get('upgradeData.upgradeGroups')[0].get('progress_percent')).to.equal(100);
- expect(controller.get('upgradeData.upgradeGroups')[0].get('completed_task_count')).to.equal(3);
- expect(controller.get('upgradeData.upgradeGroups')[0].get('upgradeItems')[0].get('status')).to.equal('COMPLETED');
- expect(controller.get('upgradeData.upgradeGroups')[0].get('upgradeItems')[0].get('progress_percent')).to.equal(100);
- expect(controller.get('upgradeData.upgradeGroups')[0].get('hasExpandableItems')).to.be.true;
- expect(controller.get('upgradeData.upgradeGroups')[1].get('status')).to.equal('ABORTED');
- expect(controller.get('upgradeData.upgradeGroups')[1].get('progress_percent')).to.equal(50);
- expect(controller.get('upgradeData.upgradeGroups')[1].get('completed_task_count')).to.equal(1);
- expect(controller.get('upgradeData.upgradeGroups')[1].get('upgradeItems')[0].get('status')).to.equal('ABORTED');
- expect(controller.get('upgradeData.upgradeGroups')[1].get('upgradeItems')[1].get('status')).to.equal('PENDING');
- expect(controller.get('upgradeData.upgradeGroups')[1].get('upgradeItems')[0].get('progress_percent')).to.equal(99);
- expect(controller.get('upgradeData.upgradeGroups')[1].get('upgradeItems')[1].get('progress_percent')).to.equal(0);
- expect(controller.get('upgradeData.upgradeGroups')[1].get('hasExpandableItems')).to.be.false;
+ ]
+ }
+ ]
+ };
+ controller.set('upgradeData', oldData);
+ controller.updateUpgradeData(newData);
+ groups = controller.get('upgradeData.upgradeGroups');
+ });
+
+ it("checking 1st group", function() {
+ expect(groups[0].get('status')).to.equal('COMPLETED');
+ expect(groups[0].get('progress_percent')).to.equal(100);
+ expect(groups[0].get('completed_task_count')).to.equal(3);
+ expect(groups[0].get('upgradeItems')[0].get('status')).to.equal('COMPLETED');
+ expect(groups[0].get('upgradeItems')[0].get('progress_percent')).to.equal(100);
+ expect(groups[0].get('hasExpandableItems')).to.be.true;
+ });
+
+ it('checking 2nd group', function () {
+ expect(groups[1].get('status')).to.equal('ABORTED');
+ expect(groups[1].get('progress_percent')).to.equal(50);
+ expect(groups[1].get('completed_task_count')).to.equal(1);
+ expect(groups[1].get('upgradeItems').mapProperty('status')).to.eql(['ABORTED', 'PENDING']);
+ expect(groups[1].get('upgradeItems').mapProperty('progress_percent')).to.eql([99, 0]);
+ expect(groups[1].get('hasExpandableItems')).to.be.false;
+ });
+
});
});
describe("#initUpgradeData()", function() {
beforeEach(function () {
sinon.stub(controller, 'setDBProperty');
- });
- afterEach(function () {
- controller.setDBProperty.restore();
- });
- it("", function() {
var newData = {
Upgrade: {
request_id: 1,
@@ -731,17 +754,24 @@ describe('App.MainAdminStackAndUpgradeController', function() {
]
};
controller.initUpgradeData(newData);
+ });
+ afterEach(function () {
+ controller.setDBProperty.restore();
+ });
+ it("setDBProperty called with valid arguments", function() {
expect(controller.setDBProperty.calledWith('downgradeAllowed', false)).to.be.true;
+ });
+ it('downgradeAllowed is false', function () {
expect(controller.get('downgradeAllowed')).to.be.false;
+ });
+ it('upgradeData.Upgrade.request_id is 1', function () {
expect(controller.get('upgradeData.Upgrade.request_id')).to.equal(1);
- expect(controller.get('upgradeData.upgradeGroups')[0].get('group_id')).to.equal(3);
- expect(controller.get('upgradeData.upgradeGroups')[1].get('group_id')).to.equal(2);
- expect(controller.get('upgradeData.upgradeGroups')[2].get('group_id')).to.equal(1);
- expect(controller.get('upgradeData.upgradeGroups')[2].get('upgradeItems')[0].get('stage_id')).to.equal(2);
- expect(controller.get('upgradeData.upgradeGroups')[2].get('upgradeItems')[1].get('stage_id')).to.equal(1);
- expect(controller.get('upgradeData.upgradeGroups')[0].get('hasExpandableItems')).to.be.false;
- expect(controller.get('upgradeData.upgradeGroups')[1].get('hasExpandableItems')).to.be.false;
- expect(controller.get('upgradeData.upgradeGroups')[2].get('hasExpandableItems')).to.be.true;
+ });
+ it('upgradeData.upgradeGroups contain valid data', function () {
+ var groups = controller.get('upgradeData.upgradeGroups');
+ expect(groups.mapProperty('group_id')).to.eql([3,2,1]);
+ expect(groups[2].get('upgradeItems').mapProperty('stage_id')).to.eql([2,1]);
+ expect(groups.mapProperty('hasExpandableItems')).to.eql([false, false, true]);
});
});
@@ -896,10 +926,11 @@ describe('App.MainAdminStackAndUpgradeController', function() {
isDowngrade: true,
upgradeType: "NON_ROLLING"
});
- expect(App.ajax.send.getCall(0).args[0].name).to.eql('admin.downgrade.start');
- expect(App.ajax.send.getCall(0).args[0].sender).to.eql(controller);
- expect(App.ajax.send.getCall(0).args[0].success).to.eql('upgradeSuccessCallback');
- expect(App.ajax.send.getCall(0).args[0].callback).to.be.called;
+ var callArgs = App.ajax.send.getCall(0).args[0];
+ expect(callArgs.name).to.eql('admin.downgrade.start');
+ expect(callArgs.sender).to.eql(controller);
+ expect(callArgs.success).to.eql('upgradeSuccessCallback');
+ expect(callArgs.callback).to.be.called;
});
});
@@ -943,21 +974,26 @@ describe('App.MainAdminStackAndUpgradeController', function() {
defaultStatus: 'INIT',
stackVersion: {}
});
- before(function () {
+ beforeEach(function () {
sinon.spy(mock, 'set');
sinon.stub(App.db, 'set', Em.K);
sinon.stub(App.clusterStatus, 'setClusterStatus', Em.K);
sinon.stub(App.RepositoryVersion, 'find').returns(mock);
+ controller.installRepoVersionSuccess({Requests: {id: 1}}, {}, {id: 1});
});
- after(function () {
+ afterEach(function () {
App.db.set.restore();
App.clusterStatus.setClusterStatus.restore();
App.RepositoryVersion.find.restore();
+ mock.set.restore();
});
- it("", function() {
- controller.installRepoVersionSuccess({Requests: {id: 1}}, {}, {id: 1});
+ it("data sdtored to the local db", function() {
expect(App.db.set.calledWith('repoVersionInstall', 'id', [1])).to.be.true;
+ });
+ it('clusterStatus is updated', function () {
expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+ });
+ it('App.RepositoryVersion models have valid states', function () {
expect(App.RepositoryVersion.find.calledWith(1)).to.be.true;
expect(App.RepositoryVersion.find(1).get('defaultStatus')).to.equal('INSTALLING');
expect(App.RepositoryVersion.find(1).get('stackVersion.state')).to.equal('INSTALLING');
@@ -968,26 +1004,25 @@ describe('App.MainAdminStackAndUpgradeController', function() {
before(function () {
sinon.stub(App.ajax, 'send', function () {
return {
- done: function (callback) {
- callback();
- }
+ done: Em.clb
}
});
});
after(function () {
App.ajax.send.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
var item = Em.Object.create({
request_id: 1,
stage_id: 1,
group_id: 1
});
controller.setUpgradeItemStatus(item, 'PENDING');
- expect(App.ajax.send.getCall(0).args[0].data).to.eql({upgradeId: 1, itemId: 1, groupId: 1, status: 'PENDING'});
- expect(App.ajax.send.getCall(0).args[0].name).to.eql('admin.upgrade.upgradeItem.setState');
- expect(App.ajax.send.getCall(0).args[0].sender).to.eql(controller);
- expect(App.ajax.send.getCall(0).args[0].callback).to.be.called;
+ var callArgs = App.ajax.send.getCall(0).args[0];
+ expect(callArgs.data).to.eql({upgradeId: 1, itemId: 1, groupId: 1, status: 'PENDING'});
+ expect(callArgs.name).to.eql('admin.upgrade.upgradeItem.setState');
+ expect(callArgs.sender).to.eql(controller);
+ expect(callArgs.callback).to.be.called;
expect(item.get('status')).to.equal('PENDING');
});
});
@@ -998,7 +1033,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
operatingSystems: [
Em.Object.create({
osType: "redhat6",
- isDisabled: Ember.computed.not('isSelected'),
+ isDisabled: Em.computed.not('isSelected'),
repositories: [Em.Object.create({
"baseUrl": "111121",
"repoId": "HDP-2.2",
@@ -1124,24 +1159,6 @@ describe('App.MainAdminStackAndUpgradeController', function() {
});
});
- describe("#showProgressPopup()", function () {
- var mock = {
- initPopup: Em.K
- };
- before(function () {
- sinon.stub(App.router, 'get').withArgs('highAvailabilityProgressPopupController').returns(mock);
- sinon.spy(mock, 'initPopup');
- });
- after(function () {
- App.router.get.restore();
- mock.initPopup.restore();
- });
- it("", function () {
- controller.showProgressPopup(Em.Object.create());
- expect(mock.initPopup.calledOnce).to.be.true;
- });
- });
-
describe("#getUrl()", function() {
beforeEach(function(){
controller.reopen({
@@ -1168,7 +1185,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
after(function () {
App.HttpClient.get.restore();
});
- it("", function () {
+ it("HttpClient did get-request", function () {
controller.loadStackVersionsToModel();
expect(App.HttpClient.get.calledOnce).to.be.true;
});
@@ -1181,7 +1198,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
after(function () {
App.HttpClient.get.restore();
});
- it("", function () {
+ it("HttpClient did get-request", function () {
controller.loadRepoVersionsToModel();
expect(App.HttpClient.get.calledOnce).to.be.true;
});
@@ -1333,23 +1350,27 @@ describe('App.MainAdminStackAndUpgradeController', function() {
describe("#suspendUpgrade()", function() {
beforeEach(function () {
sinon.stub(controller, 'abortUpgrade').returns({
- done: function (callback) {
- callback();
- }
+ done: Em.clb
});
sinon.stub(controller, 'setDBProperty', Em.K);
sinon.stub(App.clusterStatus, 'setClusterStatus', Em.K);
+ controller.suspendUpgrade();
});
afterEach(function () {
controller.abortUpgrade.restore();
controller.setDBProperty.restore();
App.clusterStatus.setClusterStatus.restore();
});
- it("", function() {
- controller.suspendUpgrade();
+ it("upgrade aborted", function() {
expect(controller.abortUpgrade.calledOnce).to.be.true;
+ });
+ it('App.upgradeState is ABORTED', function () {
expect(App.get('upgradeState')).to.equal('ABORTED');
+ });
+ it('new upgradeState is saved to the localDB', function () {
expect(controller.setDBProperty.calledWith('upgradeState', 'ABORTED')).to.be.true;
+ });
+ it('clusterStatus is updated', function () {
expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
});
});
@@ -1357,23 +1378,27 @@ describe('App.MainAdminStackAndUpgradeController', function() {
describe("#resumeUpgrade()", function() {
beforeEach(function () {
sinon.stub(controller, 'retryUpgrade').returns({
- done: function (callback) {
- callback();
- }
+ done: Em.clb
});
sinon.stub(controller, 'setDBProperty', Em.K);
sinon.stub(App.clusterStatus, 'setClusterStatus', Em.K);
+ controller.resumeUpgrade();
});
afterEach(function () {
controller.retryUpgrade.restore();
controller.setDBProperty.restore();
App.clusterStatus.setClusterStatus.restore();
});
- it("", function() {
- controller.resumeUpgrade();
+ it("Upgrade is retrying", function() {
expect(controller.retryUpgrade.calledOnce).to.be.true;
+ });
+ it('App.upgradeState is PENDING', function () {
expect(App.get('upgradeState')).to.equal('PENDING');
+ });
+ it('new upgradeState is saved to the localDB', function () {
expect(controller.setDBProperty.calledWith('upgradeState', 'PENDING')).to.be.true;
+ });
+ it('clusterStatus is updated', function () {
expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
});
});
@@ -1406,6 +1431,20 @@ describe('App.MainAdminStackAndUpgradeController', function() {
});
describe("#restoreLastUpgrade()", function () {
+
+ var data = {
+ Upgrade: {
+ request_id: 1,
+ direction: 'UPGRADE',
+ request_status: 'PENDING',
+ upgrade_type: 'ROLLING',
+ downgrade_allowed: true,
+ skip_failures: true,
+ skip_service_check_failures: true,
+ to_version: '1'
+ }
+ };
+
beforeEach(function () {
sinon.stub(App.RepositoryVersion, 'find').returns([Em.Object.create({
repositoryVersion: '1',
@@ -1422,6 +1461,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
sinon.stub(controller, 'setDBProperty');
sinon.stub(controller, 'initDBProperties');
sinon.stub(controller, 'loadUpgradeData');
+ controller.restoreLastUpgrade(data);
});
afterEach(function () {
App.RepositoryVersion.find.restore();
@@ -1431,20 +1471,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
controller.initDBProperties.restore();
controller.loadUpgradeData.restore();
});
- it("", function () {
- var data = {
- Upgrade: {
- request_id: 1,
- direction: 'UPGRADE',
- request_status: 'PENDING',
- upgrade_type: 'ROLLING',
- downgrade_allowed: true,
- skip_failures: true,
- skip_service_check_failures: true,
- to_version: '1'
- }
- };
- controller.restoreLastUpgrade(data);
+ it('proper data is saved to the localDB', function () {
expect(controller.setDBProperties.getCall(0).args[0]).to.eql({
upgradeId: 1,
isDowngrade: false,
@@ -1457,9 +1484,17 @@ describe('App.MainAdminStackAndUpgradeController', function() {
skipSCFailures: true
})
});
+ });
+ it('models are saved', function () {
expect(controller.loadRepoVersionsToModel.calledOnce).to.be.true;
+ });
+ it('correct upgradeVersion is saved to the DB', function () {
expect(controller.setDBProperty.calledWith('upgradeVersion', 'HDP-1')).to.be.true;
+ });
+ it('initDBProperties is called', function () {
expect(controller.initDBProperties.calledOnce).to.be.true;
+ });
+ it('loadUpgradeData called with valid arguments', function () {
expect(controller.loadUpgradeData.calledWith(true)).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js b/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
index 2e0208e..05ab913 100644
--- a/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
@@ -35,7 +35,7 @@ describe('App.AddAlertDefinitionController', function () {
App.ajax.send.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
controller.createNewAlertDefinition('data');
expect(App.ajax.send.getCall(0).args[0]).to.eql({
name: 'alerts.create_alert_definition',
@@ -55,7 +55,7 @@ describe('App.AddAlertDefinitionController', function () {
controller.clear.restore();
});
- it("", function () {
+ it("clear is called", function () {
controller.finish();
expect(controller.clear.calledOnce).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/alerts/alert_instances_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/alert_instances_controller_test.js b/ambari-web/test/controllers/main/alerts/alert_instances_controller_test.js
index 8958342..051202d 100644
--- a/ambari-web/test/controllers/main/alerts/alert_instances_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/alert_instances_controller_test.js
@@ -41,16 +41,18 @@ describe('App.MainAlertInstancesController', function () {
it('should load by Host name', function () {
controller.loadAlertInstancesByHost('host');
- expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances.by_host');
- expect(App.ajax.send.args[0][0].data.hostName).to.equal('host');
+ var callArgs = App.ajax.send.args[0][0];
+ expect(callArgs.name).to.equal('alerts.instances.by_host');
+ expect(callArgs.data.hostName).to.equal('host');
});
it('should load by AlertDefinition id', function () {
controller.loadAlertInstancesByAlertDefinition('1');
- expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances.by_definition');
- expect(App.ajax.send.args[0][0].data.definitionId).to.equal('1');
+ var callArgs = App.ajax.send.args[0][0];
+ expect(callArgs.name).to.equal('alerts.instances.by_definition');
+ expect(callArgs.data.definitionId).to.equal('1');
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 097fc00..530c6ad 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
@@ -28,6 +28,10 @@ function getController() {
});
}
+function getEmptyArray() {
+ return [];
+}
+
describe('App.MainAlertDefinitionConfigsController', function () {
beforeEach(function () {
@@ -40,21 +44,11 @@ describe('App.MainAlertDefinitionConfigsController', function () {
beforeEach(function () {
controller.set('content', Em.Object.create({}));
- sinon.stub(controller, 'renderPortConfigs', function () {
- return [];
- });
- sinon.stub(controller, 'renderMetricConfigs', function () {
- return [];
- });
- sinon.stub(controller, 'renderWebConfigs', function () {
- return [];
- });
- sinon.stub(controller, 'renderScriptConfigs', function () {
- return [];
- });
- sinon.stub(controller, 'renderAggregateConfigs', function () {
- return [];
- });
+ sinon.stub(controller, 'renderPortConfigs', getEmptyArray);
+ sinon.stub(controller, 'renderMetricConfigs', getEmptyArray);
+ sinon.stub(controller, 'renderWebConfigs', getEmptyArray);
+ sinon.stub(controller, 'renderScriptConfigs', getEmptyArray);
+ sinon.stub(controller, 'renderAggregateConfigs', getEmptyArray);
});
afterEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 b057a80..0ab3ea3 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
@@ -148,7 +148,7 @@ describe('MainChartHeatmapMetric', function () {
},
result: 'background-image:repeating-linear-gradient(-45deg, #FF1E10, #FF1E10 3px, #ff6c00 3px, #ff6c00 6px)'
}
- ]
+ ];
testCases.forEach(function(test){
it(test.title, function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
index a1bc7af..24497b6 100644
--- a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
+++ b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
@@ -36,50 +36,70 @@ describe('MainConfigHistoryController', function () {
});
});
describe('#load()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(controller, 'updateTotalCounter', Em.K);
sinon.stub(controller, 'loadConfigVersionsToModel').returns({done: Em.K});
-
controller.load();
- expect(controller.updateTotalCounter.calledOnce).to.be.true;
+ });
+ afterEach(function () {
controller.updateTotalCounter.restore();
controller.loadConfigVersionsToModel.restore();
});
+
+ it('updateTotalCounter is called once', function () {
+ expect(controller.updateTotalCounter.calledOnce).to.be.true;
+ });
});
describe('#loadConfigVersionsToModel()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(App.HttpClient, 'get', Em.K);
sinon.stub(controller, 'getUrl', Em.K);
sinon.stub(controller, 'getQueryParameters', function(){
return [1];
});
-
controller.loadConfigVersionsToModel();
- expect(App.HttpClient.get.calledOnce).to.be.true;
- expect(controller.getQueryParameters.calledOnce).to.be.true;
- expect(controller.getUrl.calledWith([1])).to.be.true;
-
+ });
+ afterEach(function () {
controller.getUrl.restore();
controller.getQueryParameters.restore();
App.HttpClient.get.restore();
});
+
+ it('HttpClient.get is called once', function () {
+ expect(App.HttpClient.get.calledOnce).to.be.true;
+ });
+
+ it('getQueryParameters is called once', function () {
+ expect(controller.getQueryParameters.calledOnce).to.be.true;
+ });
+
+ it('getUrl is called with correct data', function () {
+ expect(controller.getUrl.calledWith([1])).to.be.true;
+ });
});
describe('#updateTotalCounter()', function () {
- it('', function () {
- sinon.stub(App.ajax, 'send', Em.K);
+ beforeEach(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
controller.updateTotalCounter();
- expect(App.ajax.send.calledOnce).to.be.true;
+ });
+ afterEach(function () {
App.ajax.send.restore();
});
+
+ it('ajax-request is sent', function () {
+ expect(App.ajax.send.calledOnce).to.be.true;
+ });
});
describe('#updateTotalCounterSuccess()', function () {
- it('', function () {
+ it('totalCount is updated', function () {
controller.updateTotalCounterSuccess({itemTotal: 1});
expect(controller.get('totalCount')).to.equal(1);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 5c5bd32..ea9d032 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -403,7 +403,7 @@ describe('App.AddHostController', function () {
after(function () {
App.router.getClusterName.restore();
});
- it("", function () {
+ it("cluster data is valid", function () {
controller.set('clusterStatusTemplate', {'prop': 'clusterStatusTemplate'});
expect(controller.getCluster()).to.be.eql({
prop: 'clusterStatusTemplate',
@@ -601,24 +601,28 @@ describe('App.AddHostController', function () {
});
describe("#saveClients()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(App.StackServiceComponent, 'find').returns('StackServiceComponent');
sinon.stub(controller, 'getClientsToInstall').returns(['client']);
sinon.stub(controller, 'setDBProperty', Em.K);
+ controller.set('content.services', [Em.Object.create({'isSelected': true, 'isInstallable': true})]);
+ controller.saveClients();
});
- after(function () {
+ afterEach(function () {
controller.setDBProperty.restore();
App.StackServiceComponent.find.restore();
controller.getClientsToInstall.restore();
});
- it("", function () {
- controller.set('content.services', [Em.Object.create({'isSelected': true, 'isInstallable': true})]);
- controller.saveClients();
+ it("getClientsToInstall called with valid arguments", function () {
expect(controller.getClientsToInstall.calledWith(
[Em.Object.create({'isSelected': true, 'isInstallable': true})],
'StackServiceComponent'
)).to.be.true;
+ });
+ it('setDBProperty called with valid arguments', function () {
expect(controller.setDBProperty.calledWith('clientInfo', ['client'])).to.be.true;
+ });
+ it('content.clients are valid', function () {
expect(controller.get('content.clients')).to.be.eql(['client']);
});
});
@@ -752,7 +756,7 @@ describe('App.AddHostController', function () {
after(function () {
controller.getDBProperty.restore();
});
- it("", function () {
+ it("content.configGroups are valid", function () {
controller.getServiceConfigGroups();
expect(controller.get('content.configGroups')).to.eql(['serviceConfigGroup']);
});
@@ -777,23 +781,29 @@ describe('App.AddHostController', function () {
});
describe("#loadServiceConfigGroups()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(controller, 'loadServiceConfigGroupsBySlaves', Em.K);
sinon.stub(controller, 'loadServiceConfigGroupsByClients', Em.K);
sinon.stub(controller, 'sortServiceConfigGroups', Em.K);
+ controller.loadServiceConfigGroups();
});
- after(function () {
+ afterEach(function () {
controller.loadServiceConfigGroupsBySlaves.restore();
controller.loadServiceConfigGroupsByClients.restore();
controller.sortServiceConfigGroups.restore();
});
- it("", function () {
- controller.loadServiceConfigGroups();
+ it("loadServiceConfigGroupsByClients called with []", function () {
expect(controller.loadServiceConfigGroupsByClients.calledWith([])).to.be.true;
+ });
+ it('loadServiceConfigGroupsBySlaves called with []', function () {
expect(controller.loadServiceConfigGroupsBySlaves.calledWith([])).to.be.true;
+ });
+ it('sortServiceConfigGroups called with []', function () {
expect(controller.sortServiceConfigGroups.calledWith([])).to.be.true;
- expect(controller.get('content.configGroups')).to.eql([]);
});
+ it('content.configGroups are empty', function () {
+ expect(controller.get('content.configGroups')).to.eql([]);
+ })
});
describe("#sortServiceConfigGroups", function () {
@@ -1260,15 +1270,19 @@ describe('App.AddHostController', function () {
beforeEach(function () {
sinon.stub(controller, 'clearInstallOptions', Em.K);
sinon.stub(controller, 'getCluster').returns({});
+ controller.clearAllSteps();
});
afterEach(function () {
controller.clearInstallOptions.restore();
controller.getCluster.restore();
});
- it("", function () {
- controller.clearAllSteps();
+ it("getCluster called once", function () {
expect(controller.getCluster.calledOnce).to.be.true;
+ });
+ it('clearInstallOptions called once', function () {
expect(controller.clearInstallOptions.calledOnce).to.be.true;
+ });
+ it('content.cluster is empty object', function () {
expect(controller.get('content.cluster')).to.eql({});
});
});
@@ -1298,6 +1312,7 @@ describe('App.AddHostController', function () {
sinon.stub(App.router, 'get').returns(mock);
sinon.spy(mock, 'updateAll');
sinon.spy(mock, 'getAllHostNames');
+ controller.finish();
});
afterEach(function () {
controller.clearAllSteps.restore();
@@ -1307,12 +1322,19 @@ describe('App.AddHostController', function () {
mock.updateAll.restore();
mock.getAllHostNames.restore();
});
- it("", function () {
- controller.finish();
+ it("clearAllSteps called once", function () {
expect(controller.clearAllSteps.calledOnce).to.be.true;
+ });
+ it('clearStorageData called once', function () {
expect(controller.clearStorageData.calledOnce).to.be.true;
+ });
+ it('updateAll called once', function () {
expect(mock.updateAll.calledOnce).to.be.true;
+ });
+ it('App.updater.immediateRun called with valid arguments', function () {
expect(App.updater.immediateRun.calledWith('updateHost')).to.be.true;
+ });
+ it('getAllHostNames called once', function () {
expect(mock.getAllHostNames.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 0806823..9c8e4ad 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -83,12 +83,8 @@ describe('App.MainHostDetailsController', function () {
describe('#stopComponent()', function () {
beforeEach(function () {
- sinon.stub(App, 'showConfirmationPopup', function (callback) {
- callback();
- });
- sinon.stub(controller, 'checkNnLastCheckpointTime', function (callback) {
- callback();
- });
+ sinon.stub(App, 'showConfirmationPopup', Em.clb);
+ sinon.stub(controller, 'checkNnLastCheckpointTime', Em.clb);
sinon.stub(controller, 'sendComponentCommand');
});
afterEach(function () {
@@ -124,7 +120,7 @@ describe('App.MainHostDetailsController', function () {
});
describe("#pullNnCheckPointTime()", function() {
- it("", function() {
+ it("valid request is sent", function() {
controller.pullNnCheckPointTime('host1');
expect(App.ajax.send.calledWith({
name: 'common.host_component.getNnCheckPointTime',
@@ -150,10 +146,7 @@ describe('App.MainHostDetailsController', function () {
expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
"hostName": "host1",
"context": {},
- "component": Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP1'
- }),
+ "component": component,
"HostRoles": {
"state": "state"
},
@@ -179,16 +172,7 @@ describe('App.MainHostDetailsController', function () {
expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
"hostName": "host1",
"context": {},
- "component": [
- Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP1'
- }),
- Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP2'
- })
- ],
+ "component": component,
"HostRoles": {
"state": "state"
},
@@ -622,7 +606,7 @@ describe('App.MainHostDetailsController', function () {
});
describe("#loadOozieConfigs()", function() {
- it("", function() {
+ it("valid request is sent", function() {
controller.loadOozieConfigs({Clusters: {
desired_configs: {
'oozie-env': {
@@ -643,7 +627,7 @@ describe('App.MainHostDetailsController', function () {
});
describe("#loadStormConfigs()", function() {
- it("", function() {
+ it("valid request is sent", function() {
controller.loadStormConfigs({Clusters: {
desired_configs: {
'storm-site': {
@@ -663,30 +647,34 @@ describe('App.MainHostDetailsController', function () {
});
describe("#onLoadStormConfigs()", function() {
+
+ var data = {items: [
+ {
+ type: 'storm-site',
+ properties: {
+ 'nimbus.seeds': ''
+ }
+ }
+ ]};
+
beforeEach(function () {
sinon.stub(controller, 'getStormNimbusHosts').returns("host1");
sinon.stub(controller, 'updateZkConfigs', Em.K);
sinon.stub(controller, 'saveConfigsBatch', Em.K);
+ controller.set('nimbusHost', 'host2');
+ controller.onLoadStormConfigs(data);
});
afterEach(function () {
controller.getStormNimbusHosts.restore();
controller.updateZkConfigs.restore();
controller.saveConfigsBatch.restore();
});
- it("", function() {
- var data = {items: [
- {
- type: 'storm-site',
- properties: {
- 'nimbus.seeds': ''
- }
- }
- ]};
- controller.set('nimbusHost', 'host2');
- controller.onLoadStormConfigs(data);
+ it("updateZkConfigs called with valid arguments", function() {
expect(controller.updateZkConfigs.calledWith({'storm-site': {
'nimbus.seeds': "'host1'"
}})).to.be.true;
+ });
+ it('saveConfigsBatch called with valid arguments', function () {
expect(controller.saveConfigsBatch.calledWith([
{
properties: {
@@ -703,7 +691,7 @@ describe('App.MainHostDetailsController', function () {
});
describe("#loadHiveConfigs()", function() {
- it("", function() {
+ it("valid request is sent", function() {
controller.loadHiveConfigs({Clusters: {
desired_configs: {
'hive-site': {
@@ -732,7 +720,7 @@ describe('App.MainHostDetailsController', function () {
});
describe("#loadRangerConfigs()", function() {
- it("", function() {
+ it("valid request is sent", function() {
controller.loadRangerConfigs({Clusters: {
desired_configs: {
'hdfs-site': {
@@ -763,18 +751,25 @@ describe('App.MainHostDetailsController', function () {
componentName: 'RANGER_KMS_SERVER',
hostName: 'host1'
}]);
- });
- afterEach(function(){
- App.HostComponent.find.restore();
- });
- it("", function() {
controller.set('rangerKMSServerHost', 'host2');
controller.set('content.hostName', 'host1');
controller.set('deleteRangerKMSServer', true);
controller.set('fromDeleteHost', true);
- expect(controller.getRangerKMSServerHosts()).to.eql(['host2']);
+ this.hosts = controller.getRangerKMSServerHosts();
+ });
+ afterEach(function(){
+ App.HostComponent.find.restore();
+ });
+ it('hosts list is valid', function() {
+ expect(this.hosts).to.eql(['host2']);
+ });
+ it('rangerKMSServerHost is empty', function () {
expect(controller.get('rangerKMSServerHost')).to.be.empty;
+ });
+ it('deleteRangerKMSServer is false', function () {
expect(controller.get('deleteRangerKMSServer')).to.be.false;
+ });
+ it('fromDeleteHost is false', function () {
expect(controller.get('fromDeleteHost')).to.be.false;
});
});
@@ -785,18 +780,25 @@ describe('App.MainHostDetailsController', function () {
componentName: 'NIMBUS',
hostName: 'host1'
}]);
- });
- afterEach(function(){
- App.HostComponent.find.restore();
- });
- it("", function() {
controller.set('nimbusHost', 'host2');
controller.set('content.hostName', 'host1');
controller.set('deleteNimbusHost', true);
controller.set('fromDeleteHost', true);
- expect(controller.getStormNimbusHosts()).to.eql(['host2']);
+ this.hosts = controller.getStormNimbusHosts();
+ });
+ afterEach(function(){
+ App.HostComponent.find.restore();
+ });
+ it("hosts list is valid", function() {
+ expect(this.hosts).to.eql(['host2']);
+ });
+ it('nimbusHost is empty', function () {
expect(controller.get('nimbusHost')).to.be.empty;
+ });
+ it('deleteNimbusHost is false', function () {
expect(controller.get('deleteNimbusHost')).to.be.false;
+ });
+ it('fromDeleteHost is false', function () {
expect(controller.get('fromDeleteHost')).to.be.false;
});
});
@@ -1452,8 +1454,14 @@ describe('App.MainHostDetailsController', function () {
});
describe('#checkRegionServerState()', function () {
- it('', function () {
- expect(controller.checkRegionServerState('host1')).to.be.an('object');
+ var result;
+ beforeEach(function () {
+ result = controller.checkRegionServerState('host1');
+ });
+ it('returns object', function () {
+ expect(result).to.be.an('object');
+ });
+ it('request is sent with correct data', function () {
expect(App.ajax.send.getCall(0).args[0].data.hostNames).to.equal('host1');
});
});
@@ -1536,7 +1544,7 @@ describe('App.MainHostDetailsController', function () {
afterEach(function () {
App.ModalPopup.show.restore();
});
- it('', function () {
+ it('modal popup is shown', function () {
controller.showRegionServerWarning();
expect(App.ModalPopup.show.calledOnce).to.be.true;
});
@@ -1666,7 +1674,7 @@ describe('App.MainHostDetailsController', function () {
afterEach(function() {
hostsManagement.setRackInfo.restore();
});
- it("", function() {
+ it('setRackInfo called with valid arguments', function() {
controller.set('content.rack', 'rack');
controller.set('content.hostName', 'host1');
controller.setRackIdForHost();
@@ -2946,25 +2954,29 @@ describe('App.MainHostDetailsController', function () {
});
describe("#installVersionSuccessCallback()", function () {
- before(function () {
+ var version = Em.Object.create({
+ id: 1,
+ status: 'INIT'
+ });
+ beforeEach(function () {
this.mock = sinon.stub(App.HostStackVersion, 'find');
+ this.mock.returns(version);
sinon.stub(App.db, 'set', Em.K);
sinon.stub(App.clusterStatus, 'setClusterStatus', Em.K);
+ controller.installVersionSuccessCallback({Requests: {id: 1}}, {}, {version: version});
});
- after(function () {
+ afterEach(function () {
this.mock.restore();
App.db.set.restore();
App.clusterStatus.setClusterStatus.restore();
});
- it("", function () {
- var version = Em.Object.create({
- id: 1,
- status: 'INIT'
- });
- this.mock.returns(version);
- controller.installVersionSuccessCallback({Requests: {id: 1}}, {}, {version: version});
+ it("status is INSTALLING", function () {
expect(version.get('status')).to.equal('INSTALLING');
+ });
+ it('valid data is saved to the localDB', function () {
expect(App.db.set.calledWith('repoVersionInstall', 'id', [1])).to.be.true;
+ });
+ it('clusterStatus is updated', function () {
expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
});
});
@@ -3165,7 +3177,16 @@ describe('App.MainHostDetailsController', function () {
});
describe("#removeHostComponentModel()", function () {
+
beforeEach(function () {
+ App.cache['services'] = [
+ {
+ ServiceInfo: {
+ service_name: 'S1'
+ },
+ host_components: ['C1_host1']
+ }
+ ];
sinon.stub(App.HostComponent, 'find').returns([
Em.Object.create({
id: 'C1_host1',
@@ -3177,23 +3198,16 @@ describe('App.MainHostDetailsController', function () {
})
]);
sinon.stub(App.serviceMapper, 'deleteRecord', Em.K);
+ controller.removeHostComponentModel('C1', 'host1');
});
afterEach(function () {
App.HostComponent.find.restore();
App.serviceMapper.deleteRecord.restore();
});
- it("", function () {
- App.cache['services'] = [
- {
- ServiceInfo: {
- service_name: 'S1'
- },
- host_components: ['C1_host1']
- }
- ];
- controller.removeHostComponentModel('C1', 'host1');
+ it("App.cache is updated", function () {
expect(App.cache['services'][0].host_components).to.be.empty;
- expect(App.HostComponent.find.calledOnce).to.be.true;
+ });
+ it('Record is deleted', function () {
expect(App.serviceMapper.deleteRecord.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/host/host_alerts_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/host_alerts_controller_test.js b/ambari-web/test/controllers/main/host/host_alerts_controller_test.js
index 2cfdac5..fadc106 100644
--- a/ambari-web/test/controllers/main/host/host_alerts_controller_test.js
+++ b/ambari-web/test/controllers/main/host/host_alerts_controller_test.js
@@ -45,9 +45,8 @@ describe('App.MainHostAlertsController', function () {
App.router.transitionTo.restore();
});
- it("", function () {
+ it("transitionTo is called with valid route and data", function () {
controller.routeToAlertDefinition({context: 'id'});
- expect(App.AlertDefinition.find.calledWith('id')).to.be.true;
expect(App.router.transitionTo.calledWith('main.alerts.alertDetails', 'alertDefinition')).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 bec3be1..28c13e3 100644
--- a/ambari-web/test/controllers/main/service/info/summary_test.js
+++ b/ambari-web/test/controllers/main/service/info/summary_test.js
@@ -304,24 +304,22 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS
beforeEach(function () {
sinon.stub(App.widgetLayoutMapper, 'map');
sinon.stub(controller, 'propertyDidChange');
- });
- afterEach(function () {
- App.widgetLayoutMapper.map.restore();
- controller.propertyDidChange.restore();
- });
- it("", function () {
var params = {
data: {
WidgetLayoutInfo: {
widgets: [
- {
- id: 1
- }
+ {id: 1}
]
}
}
};
controller.hideWidgetSuccessCallback({}, {}, params);
+ });
+ afterEach(function () {
+ App.widgetLayoutMapper.map.restore();
+ controller.propertyDidChange.restore();
+ });
+ it("mapper is called with valid data", function () {
expect(App.widgetLayoutMapper.map.calledWith({
items: [{
WidgetLayoutInfo: {
@@ -335,6 +333,8 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS
}
}]
})).to.be.true;
+ });
+ it('`widgets` is forced to be recalculated', function () {
expect(controller.propertyDidChange.calledWith('widgets')).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 4934d21..8794661 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -234,7 +234,7 @@ describe('App.MainServiceItemController', function () {
describe("#startStopPopupPrimary", function () {
-
+ var mainServiceItemController;
var tests = [
{
data: {
@@ -283,16 +283,25 @@ describe('App.MainServiceItemController', function () {
});
- tests.forEach(function (test) {
- it('', function () {
- var mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}});
+ tests.forEach(function (test, index) {
+
+ function setupWithTestData() {
+ mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}});
mainServiceItemController.startStopPopupPrimary(test.data.state, test.data.query);
- expect($.ajax.calledOnce).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);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 bfc88f4..dffeabb 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
@@ -26,54 +26,54 @@ describe('App.ManageConfigGroupsController', function() {
c = App.ManageConfigGroupsController.create({});
});
- var manageConfigGroupsController = App.ManageConfigGroupsController.create({});
+ var manageConfigGroupsController = App.ManageConfigGroupsController.create({});
- describe('#addConfigGroup', function() {
- beforeEach(function() {
- manageConfigGroupsController.addConfigGroup();
- });
+ describe('#addConfigGroup', function() {
+ beforeEach(function() {
+ manageConfigGroupsController.addConfigGroup();
+ });
- describe("#validate", function() {
- it("should display no warning if user inputs valid characters into group name", function() {
+ describe("#validate", function() {
+ it("should display no warning if user inputs valid characters into group name", function() {
- manageConfigGroupsController.addGroupPopup.set('configGroupName', 'hello');
+ manageConfigGroupsController.addGroupPopup.set('configGroupName', 'hello');
- expect(manageConfigGroupsController.addGroupPopup.warningMessage).to.be.empty;
- });
+ expect(manageConfigGroupsController.addGroupPopup.warningMessage).to.be.empty;
+ });
- it("should display warning if user inputs invalid characters into group name", function() {
- manageConfigGroupsController.addGroupPopup.set('configGroupName', '/{"!@#$%');
+ it("should display warning if user inputs invalid characters into group name", function() {
+ manageConfigGroupsController.addGroupPopup.set('configGroupName', '/{"!@#$%');
- expect(manageConfigGroupsController.addGroupPopup.warningMessage).to.equal('Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.');
- });
- });
- });
+ expect(manageConfigGroupsController.addGroupPopup.warningMessage).to.equal('Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.');
+ });
+ });
+ });
- describe('#renameConfigGroup', function() {
- beforeEach(function() {
- var configGroup = Ember.Object.create ({
- name: 'name',
- description: 'description'
- });
+ describe('#renameConfigGroup', function() {
+ beforeEach(function() {
+ var configGroup = Ember.Object.create ({
+ name: 'name',
+ description: 'description'
+ });
- manageConfigGroupsController.set('selectedConfigGroup', configGroup);
- manageConfigGroupsController.renameConfigGroup();
- });
+ manageConfigGroupsController.set('selectedConfigGroup', configGroup);
+ manageConfigGroupsController.renameConfigGroup();
+ });
- describe("#validate", function() {
- it("should display no warning if user inputs valid characters into group name", function() {
- manageConfigGroupsController.renameGroupPopup.set('configGroupName', 'hello');
+ describe("#validate", function() {
+ it("should display no warning if user inputs valid characters into group name", function() {
+ manageConfigGroupsController.renameGroupPopup.set('configGroupName', 'hello');
- expect(manageConfigGroupsController.renameGroupPopup.warningMessage).to.be.empty;
- });
+ expect(manageConfigGroupsController.renameGroupPopup.warningMessage).to.be.empty;
+ });
- it("should display warning if user inputs invalid characters into group name", function() {
- manageConfigGroupsController.renameGroupPopup.set('configGroupName', '/{"!@#$%');
+ it("should display warning if user inputs invalid characters into group name", function() {
+ manageConfigGroupsController.renameGroupPopup.set('configGroupName', '/{"!@#$%');
- expect(manageConfigGroupsController.renameGroupPopup.warningMessage).to.equal('Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.');
- });
- });
- });
+ expect(manageConfigGroupsController.renameGroupPopup.warningMessage).to.equal('Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.');
+ });
+ });
+ });
describe('#addHostsCallback', function() {
@@ -102,60 +102,60 @@ describe('App.ManageConfigGroupsController', function() {
describe('#isHostsModified', function () {
Em.A([
- {
- o: {
- toClearHosts: [],
- toDelete: [],
- toSetHosts: [],
- toCreate: []
- },
- e: false
+ {
+ o: {
+ toClearHosts: [],
+ toDelete: [],
+ toSetHosts: [],
+ toCreate: []
+ },
+ e: false
+ },
+ {
+ o: {
+ toClearHosts: [{}],
+ toDelete: [],
+ toSetHosts: [],
+ toCreate: []
},
- {
- o: {
- toClearHosts: [{}],
- toDelete: [],
- toSetHosts: [],
- toCreate: []
- },
- e: true
+ e: true
+ },
+ {
+ o: {
+ toClearHosts: [],
+ toDelete: [{}],
+ toSetHosts: [],
+ toCreate: []
},
- {
- o: {
- toClearHosts: [],
- toDelete: [{}],
- toSetHosts: [],
- toCreate: []
- },
- e: true
+ e: true
+ },
+ {
+ o: {
+ toClearHosts: [],
+ toDelete: [],
+ toSetHosts: [{}],
+ toCreate: []
},
- {
- o: {
- toClearHosts: [],
- toDelete: [],
- toSetHosts: [{}],
- toCreate: []
- },
- e: true
+ e: true
+ },
+ {
+ o: {
+ toClearHosts: [],
+ toDelete: [],
+ toSetHosts: [],
+ toCreate: [{}]
},
- {
- o: {
- toClearHosts: [],
- toDelete: [],
- toSetHosts: [],
- toCreate: [{}]
- },
- e: true
- }
+ e: true
+ }
]).forEach(function (test, index) {
- it('test #' + index, function () {
- c.reopen({
- isLoaded: true,
- hostsModifiedConfigGroups: test.o
- });
- expect(c.get('isHostsModified')).to.equal(test.e);
+ it('test #' + index, function () {
+ c.reopen({
+ isLoaded: true,
+ hostsModifiedConfigGroups: test.o
});
+ expect(c.get('isHostsModified')).to.equal(test.e);
});
+ });
});
@@ -206,7 +206,7 @@ describe('App.ManageConfigGroupsController', function() {
afterEach(function () {
popup.onPrimaryWizard.restore();
});
- it("", function () {
+ it("onPrimaryWizard is called", function () {
popup.onPrimary();
expect(popup.onPrimaryWizard.calledOnce).to.be.true;
});
@@ -297,6 +297,8 @@ describe('App.ManageConfigGroupsController', function() {
});
sinon.stub(popup, 'updateConfigGroupOnServicePage', Em.K);
sinon.stub(popup, 'hide', Em.K);
+ manageConfigGroupsController.set('hostsModifiedConfigGroups', {toCreate: []});
+ popup.onPrimary();
});
afterEach(function () {
popup.runCreateCGQueue.restore();
@@ -305,13 +307,19 @@ describe('App.ManageConfigGroupsController', function() {
popup.updateConfigGroupOnServicePage.restore();
popup.hide.restore();
});
- it("", function () {
- manageConfigGroupsController.set('hostsModifiedConfigGroups', {toCreate: []});
- popup.onPrimary();
+ it("runClearCGQueue is called", function () {
expect(popup.runClearCGQueue.calledOnce).to.be.true;
+ });
+ it("runModifyCGQueue is called", function () {
expect(popup.runModifyCGQueue.calledOnce).to.be.true;
+ });
+ it("runCreateCGQueue is called", function () {
expect(popup.runCreateCGQueue.calledOnce).to.be.true;
+ });
+ it("updateConfigGroupOnServicePage is called", function () {
expect(popup.updateConfigGroupOnServicePage.calledOnce).to.be.true;
+ });
+ it("hide is called", function () {
expect(popup.hide.calledOnce).to.be.true;
});
});
@@ -319,18 +327,20 @@ describe('App.ManageConfigGroupsController', function() {
beforeEach(function () {
sinon.stub(manageConfigGroupsController, 'updateConfigurationGroup', Em.K);
sinon.stub(manageConfigGroupsController, 'deleteConfigurationGroup', Em.K);
- });
- afterEach(function () {
- manageConfigGroupsController.updateConfigurationGroup.restore();
- manageConfigGroupsController.deleteConfigurationGroup.restore();
- });
- it("", function () {
popup.runClearCGQueue(Em.K, {
initialGroups: [],
toClearHosts: [Em.Object.create()],
toDelete: [1]
});
+ });
+ afterEach(function () {
+ manageConfigGroupsController.updateConfigurationGroup.restore();
+ manageConfigGroupsController.deleteConfigurationGroup.restore();
+ });
+ it("updateConfigurationGroup is called once", function () {
expect(manageConfigGroupsController.updateConfigurationGroup.calledOnce).to.be.true;
+ });
+ it("deleteConfigurationGroup is called once", function () {
expect(manageConfigGroupsController.deleteConfigurationGroup.calledOnce).to.be.true;
});
});
@@ -341,7 +351,7 @@ describe('App.ManageConfigGroupsController', function() {
afterEach(function () {
manageConfigGroupsController.updateConfigurationGroup.restore();
});
- it("", function () {
+ it("updateConfigurationGroup is called once", function () {
popup.runModifyCGQueue(Em.K, {toSetHosts: [1]});
expect(manageConfigGroupsController.updateConfigurationGroup.calledOnce).to.be.true;
});
@@ -353,7 +363,7 @@ describe('App.ManageConfigGroupsController', function() {
afterEach(function () {
manageConfigGroupsController.postNewConfigurationGroup.restore();
});
- it("", function () {
+ it("postNewConfigurationGroup is called once", function () {
popup.runCreateCGQueue(Em.K, {toCreate: [1]});
expect(manageConfigGroupsController.postNewConfigurationGroup.calledOnce).to.be.true;
});
[2/3] ambari git commit: AMBARI-14356.
hostWarningPopupBody_view_test.js unit test failing intermittently
(onechiporenko)
Posted by on...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
index a341587..7521d93 100644
--- a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
@@ -96,7 +96,7 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
});
describe("#mastersToShow", function() {
- it("", function() {
+ it("should be like array with `content.reassign.component_name`", function() {
controller.set('content.reassign.component_name', 'C1');
controller.propertyDidChange('mastersToShow');
expect(controller.get('mastersToShow')).to.eql(['C1']);
@@ -104,7 +104,7 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
});
describe("#mastersToMove", function() {
- it("", function() {
+ it("should be like array with `content.reassign.component_name`", function() {
controller.set('content.reassign.component_name', 'C1');
controller.propertyDidChange('mastersToMove');
expect(controller.get('mastersToMove')).to.eql(['C1']);
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/service/reassign/step3_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step3_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step3_controller_test.js
index 713eaed..e433f47 100644
--- a/ambari-web/test/controllers/main/service/reassign/step3_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step3_controller_test.js
@@ -32,19 +32,21 @@ describe('App.ReassignMasterWizardStep3Controller', function () {
callback();
}
};
- before(function () {
+ beforeEach(function () {
sinon.stub(App, 'get').returns(mock);
sinon.spy(mock, 'getKDCSessionState');
sinon.stub(App.router, 'send', Em.K);
+ controller.submit();
});
- after(function () {
+ afterEach(function () {
App.get.restore();
mock.getKDCSessionState.restore();
App.router.send.restore();
});
- it("", function () {
- controller.submit();
+ it('getKDCSessionState is called once', function () {
expect(mock.getKDCSessionState.calledOnce).to.be.true;
+ });
+ it('User is moved to the next step', function () {
expect(App.router.send.calledWith("next")).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 fd614a5..3b37770 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
@@ -315,7 +315,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
after(function () {
controller.stopServices.restore();
});
- it("", function() {
+ it('stopServices is called with valid list of services', function() {
controller.set('content.reassign.component_name', 'JOBTRACKER');
controller.stopRequiredServices();
expect(controller.stopServices.calledWith(['HDFS', 'ZOOKEEPER', 'HBASE', 'FLUME', 'SQOOP', 'STORM'])).to.be.true;
@@ -334,7 +334,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.getHostComponentsNames.restore();
this.mock.restore();
});
- it('No commands', function () {
+ it('No commands (isComponentWithDB = false)', function () {
controller.set('commands', []);
controller.set('commandsForDB', []);
this.mock.returns(false);
@@ -342,7 +342,8 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
expect(controller.get('tasks')).to.be.empty;
});
- it('No commands', function () {
+
+ it('No commands (isComponentWithDB = true)', function () {
controller.set('commands', []);
controller.set('commandsForDB', []);
this.mock.returns(true);
@@ -350,6 +351,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
expect(controller.get('tasks')).to.be.empty;
});
+
it('One command', function () {
controller.set('commands', ['COMMAND1']);
controller.set('commandsForDB', ['COMMAND1']);
@@ -415,7 +417,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe('#stopServices()', function () {
- it('', function () {
+ it('request is sent', function () {
controller.stopServices();
expect(App.ajax.send.calledOnce).to.be.true;
});
@@ -450,11 +452,18 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe('#onCreateComponent()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(controller, 'onComponentsTasksSuccess', Em.K);
+ });
+
+ afterEach(function () {
+ controller.onComponentsTasksSuccess.restore();
+ });
+
+ it('onComponentsTasksSuccess is called once', function () {
controller.onCreateComponent();
expect(controller.onComponentsTasksSuccess.calledOnce).to.be.true;
- controller.onComponentsTasksSuccess.restore();
});
});
@@ -509,16 +518,23 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe('#reconfigure()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(controller, 'loadConfigsTags', Em.K);
+ });
+
+ afterEach(function () {
+ controller.loadConfigsTags.restore();
+ });
+
+ it('loadConfigsTags is called once', function () {
controller.reconfigure();
expect(controller.loadConfigsTags.calledOnce).to.be.true;
- controller.loadConfigsTags.restore();
});
});
describe('#loadConfigsTags()', function () {
- it('', function () {
+ it('request is sent', function () {
controller.loadConfigsTags();
expect(App.ajax.send.calledOnce).to.be.true;
});
@@ -663,18 +679,26 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe('#onLoadConfigsTags()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(controller, 'getConfigUrlParams', function () {
return [];
});
controller.set('content.reassign.component_name', 'COMP1');
-
controller.onLoadConfigsTags({});
- expect(App.ajax.send.calledOnce).to.be.true;
- expect(controller.getConfigUrlParams.calledWith('COMP1', {})).to.be.true;
+ });
+ afterEach(function () {
controller.getConfigUrlParams.restore();
});
+
+ it('request is sent', function () {
+ expect(App.ajax.send.calledOnce).to.be.true;
+ });
+
+ it('getConfigUrlParams is called with correct data', function () {
+ expect(controller.getConfigUrlParams.calledWith('COMP1', {})).to.be.true;
+ });
});
describe('#loadStep()', function () {
@@ -731,25 +755,31 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
describe('#saveConfigsToServer()', function () {
beforeEach(function () {
sinon.stub(controller, 'getServiceConfigData', Em.K);
+ controller.saveConfigsToServer([1]);
});
afterEach(function () {
controller.getServiceConfigData.restore();
});
- it('', function () {
- controller.saveConfigsToServer([1]);
+ it('getServiceConfigData is called with valid data', function () {
expect(controller.getServiceConfigData.calledWith([1])).to.be.true;
+ });
+ it('request is sent', function () {
expect(App.ajax.send.calledOnce).to.be.true;
});
});
describe('#setSecureConfigs()', function () {
+
+ afterEach(function () {
+ Em.tryInvoke(App.get, 'restore');
+ });
+
it('undefined component and security disabled', function () {
var secureConfigs = [];
sinon.stub(App, 'get').withArgs('isKerberosEnabled').returns(false);
controller.set('secureConfigsMap', []);
expect(controller.setSecureConfigs(secureConfigs, {}, 'COMP1')).to.be.false;
expect(secureConfigs).to.eql([]);
- App.get.restore();
});
it('component exist and security disabled', function () {
var secureConfigs = [];
@@ -759,7 +789,6 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
}]);
expect(controller.setSecureConfigs(secureConfigs, {}, 'COMP1')).to.be.false;
expect(secureConfigs).to.eql([]);
- App.get.restore();
});
it('undefined component and security enabled', function () {
var secureConfigs = [];
@@ -767,7 +796,6 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.set('secureConfigsMap', []);
expect(controller.setSecureConfigs(secureConfigs, {}, 'COMP1')).to.be.false;
expect(secureConfigs).to.eql([]);
- App.get.restore();
});
it('component exist and security enabled', function () {
var secureConfigs = [];
@@ -791,7 +819,6 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
"principal": "pValue"
}
]);
- App.get.restore();
});
});
@@ -866,7 +893,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.onTaskCompleted.restore();
});
- it('', function () {
+ it('onTaskCompleted called once', function () {
controller.onSaveConfigs();
expect(controller.onTaskCompleted.calledOnce).to.be.true;
});
@@ -880,7 +907,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.updateComponent.restore();
});
- it('', function () {
+ it('updateComponent called with valid arguments', function () {
controller.set('content.masterComponentHosts', [{
component: 'ZOOKEEPER_SERVER',
hostName: 'host1'
@@ -922,14 +949,14 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe('#startServices()', function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(App.router, 'get').returns({"skip.service.checks": "false"});
+ controller.startServices();
});
- after(function () {
+ afterEach(function () {
App.router.get.restore();
});
- it('', function () {
- controller.startServices();
+ it('request is sent', function () {
expect(App.ajax.send.calledOnce).to.be.true;
});
});
@@ -970,14 +997,14 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
it('task success', function () {
var error = {
responseText: 'org.apache.ambari.server.controller.spi.NoSuchResourceException'
- }
+ };
controller.onDeleteHostComponentsError(error);
expect(controller.onComponentsTasksSuccess.calledOnce).to.be.true;
});
it('unknown error', function () {
var error = {
responseText: ''
- }
+ };
controller.onDeleteHostComponentsError(error);
expect(controller.onTaskError.calledOnce).to.be.true;
});
@@ -1041,7 +1068,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.set('content.reassign.component_name', 'COMP1');
expect(controller.getServiceConfigData([])).to.eql([]);
});
- it('Services in stackServicesm but configTypesRendered is empty', function () {
+ it('Services in stackServices, but configTypesRendered is empty', function () {
services = [Em.Object.create({serviceName: 'S1'})];
stackServices = [Em.Object.create({
serviceName: 'S1',
@@ -1050,7 +1077,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.set('content.reassign.component_name', 'COMP1');
expect(controller.getServiceConfigData([])[0]).to.equal("{\"Clusters\":{\"desired_config\":[]}}");
});
- it('Services in stackServicesm and configTypesRendered has data, but configs is empty', function () {
+ it('Services in stackServices, and configTypesRendered has data, but configs is empty', function () {
services = [Em.Object.create({serviceName: 'S1'})];
stackServices = [
Em.Object.create({
@@ -1061,7 +1088,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
controller.set('content.reassign.component_name', 'COMP1');
expect(controller.getServiceConfigData([])[0]).to.equal("{\"Clusters\":{\"desired_config\":[]}}");
});
- it('Services in stackServicesm and configTypesRendered has data, and configs present', function () {
+ it('Services in stackServices, and configTypesRendered has data, and configs present', function () {
services = [Em.Object.create({serviceName: 'S1'})];
stackServices = [
Em.Object.create({
@@ -1200,7 +1227,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
afterEach(function () {
App.HostComponent.find.restore();
});
- it("", function() {
+ it("valid request is sent", function() {
controller.startMySqlServer();
expect(App.ajax.send.calledWith({
name: 'common.host.host_component.update',
@@ -1232,7 +1259,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
afterEach(function () {
App.HostComponent.find.restore();
});
- it("", function() {
+ it("valid request is sent", function() {
controller.set('content', Em.Object.create({
cluster: Em.Object.create({
name: 'cl1'
@@ -1263,13 +1290,17 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe("#startNewMySqlServer()", function() {
- it("", function() {
+
+ beforeEach(function () {
controller.set('content', Em.Object.create({
reassignHosts: Em.Object.create({
target: 'host1'
})
}));
controller.startNewMySqlServer();
+ });
+
+ it('valid request is sent', function() {
expect(App.ajax.send.calledWith({
name: 'common.host.host_component.update',
sender: controller,
@@ -1546,12 +1577,6 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
'java.home': 'java.home'
});
sinon.stub(controller, 'getConnectionProperty').returns('prop1');
- });
- afterEach(function () {
- App.router.get.restore();
- controller.getConnectionProperty.restore();
- });
- it("", function () {
controller.set('content.reassignHosts', Em.Object.create({target: 'host1'}));
controller.reopen({
dbType: 'type1',
@@ -1559,10 +1584,17 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
preparedDBProperties: {}
});
controller.prepareDBCheckAction();
- expect(App.ajax.send.getCall(0).args[0].name).to.equal('cluster.custom_action.create');
- expect(App.ajax.send.getCall(0).args[0].success).to.equal('onCreateActionSuccess');
- expect(App.ajax.send.getCall(0).args[0].error).to.equal('onTaskError');
- expect(App.ajax.send.getCall(0).args[0].data).to.eql({
+ });
+ afterEach(function () {
+ App.router.get.restore();
+ controller.getConnectionProperty.restore();
+ });
+ it('valid request is sent', function () {
+ var callArgs = App.ajax.send.getCall(0).args[0];
+ expect(callArgs.name).to.equal('cluster.custom_action.create');
+ expect(callArgs.success).to.equal('onCreateActionSuccess');
+ expect(callArgs.error).to.equal('onTaskError');
+ expect(callArgs.data).to.eql({
requestInfo: {
"context": "Check host",
"action": "check_host",
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
index be3c8fe..9ab1144 100644
--- a/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
@@ -247,7 +247,7 @@ describe('App.ReassignMasterWizardStep6Controller', function () {
afterEach(function () {
controller.startServices.restore();
});
- it("", function () {
+ it("startServices is called with valid arguments", function () {
controller.startAllServices();
expect(controller.startServices.calledWith(true)).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/service/widgets/create/step1_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/widgets/create/step1_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step1_controller_test.js
index 8ceb669..9d1efc0 100644
--- a/ambari-web/test/controllers/main/service/widgets/create/step1_controller_test.js
+++ b/ambari-web/test/controllers/main/service/widgets/create/step1_controller_test.js
@@ -38,15 +38,17 @@ describe('App.WidgetWizardStep1Controller', function () {
});
describe("#chooseOption()", function () {
- before(function () {
+ beforeEach(function () {
sinon.stub(controller, 'next');
+ controller.chooseOption({context: 'type1'});
});
- after(function () {
+ afterEach(function () {
controller.next.restore();
});
- it("", function () {
- controller.chooseOption({context: 'type1'});
+ it('widgetType is valid', function () {
expect(controller.get('widgetType')).to.equal('type1');
+ });
+ it('User is moved to the next step', function () {
expect(controller.next.calledOnce).to.be.true;
});
});
@@ -58,14 +60,14 @@ describe('App.WidgetWizardStep1Controller', function () {
after(function () {
controller.clearStep.restore();
});
- it("", function () {
+ it("clearStep", function () {
controller.loadStep();
expect(controller.clearStep.calledOnce).to.be.true;
});
});
describe("#clearStep()", function () {
- it("", function () {
+ it("widgetType is empty", function () {
controller.clearStep();
expect(controller.get('widgetType')).to.be.empty;
});
@@ -78,7 +80,7 @@ describe('App.WidgetWizardStep1Controller', function () {
after(function () {
App.router.send.restore();
});
- it("", function () {
+ it("user is moved to the next step", function () {
controller.next();
expect(App.router.send.calledWith('next')).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
index 9d3efde..3178ef5 100644
--- a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
@@ -221,20 +221,28 @@ describe('App.WidgetWizardStep2Controller', function () {
});
describe("#addDataSet()", function () {
- it("", function () {
+
+ beforeEach(function () {
controller.get('dataSets').clear();
controller.addDataSet(null, true);
- expect(controller.get('dataSets').objectAt(0).get('id')).to.equal(1);
- expect(controller.get('dataSets').objectAt(0).get('isRemovable')).to.equal(false);
controller.addDataSet(null);
- expect(controller.get('dataSets').objectAt(1).get('id')).to.equal(2);
- expect(controller.get('dataSets').objectAt(1).get('isRemovable')).to.equal(true);
+ });
+
+ afterEach(function() {
controller.get('dataSets').clear();
});
+
+ it('check id', function () {
+ expect(controller.get('dataSets').mapProperty('id')).to.eql([1, 2]);
+ });
+
+ it('check isRemovable', function () {
+ expect(controller.get('dataSets').mapProperty('isRemovable')).to.eql([false, true]);
+ });
});
describe("#removeDataSet()", function () {
- it("", function () {
+ it('should remove selected dataSet', function () {
var dataSet = Em.Object.create();
controller.get('dataSets').pushObject(dataSet);
controller.removeDataSet({context: dataSet});
@@ -243,20 +251,29 @@ describe('App.WidgetWizardStep2Controller', function () {
});
describe("#addExpression()", function () {
- it("", function () {
+
+ beforeEach(function () {
controller.get('expressions').clear();
controller.addExpression(null, true);
- expect(controller.get('expressions').objectAt(0).get('id')).to.equal(1);
- expect(controller.get('expressions').objectAt(0).get('isRemovable')).to.equal(false);
controller.addExpression(null);
- expect(controller.get('expressions').objectAt(1).get('id')).to.equal(2);
- expect(controller.get('expressions').objectAt(1).get('isRemovable')).to.equal(true);
+ });
+
+ afterEach(function () {
controller.get('expressions').clear();
});
+
+ it('check id', function () {
+ expect(controller.get('expressions').mapProperty('id')).to.eql([1, 2]);;
+ });
+
+ it('check isRemovable', function () {
+ expect(controller.get('expressions').mapProperty('isRemovable')).to.eql([false, true]);
+ });
+
});
describe("#removeExpression()", function () {
- it("", function () {
+ it("should remove selected expression", function () {
var expression = Em.Object.create();
controller.get('expressions').pushObject(expression);
controller.removeExpression({context: expression});
@@ -582,7 +599,7 @@ describe('App.WidgetWizardStep2Controller', function () {
afterEach(function () {
App.router.send.restore();
});
- it("", function () {
+ it("user is moved to the next step", function () {
controller.next();
expect(App.router.send.calledWith('next'));
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js
index 144918e..6f92142 100644
--- a/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js
+++ b/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js
@@ -39,11 +39,6 @@ describe('App.WidgetWizardStep3Controller', function () {
describe("#initPreviewData()", function () {
beforeEach(function () {
sinon.stub(controller, 'addObserver');
- });
- afterEach(function () {
- controller.addObserver.restore();
- });
- it("", function () {
controller.set('content', Em.Object.create({
widgetProperties: 'widgetProperties',
widgetValues: 'widgetValues',
@@ -55,15 +50,36 @@ describe('App.WidgetWizardStep3Controller', function () {
controllerName: 'widgetEditController'
}));
controller.initPreviewData();
+ });
+ afterEach(function () {
+ controller.addObserver.restore();
+ });
+ it('checking observes calls', function () {
controller.get('isSharedCheckboxDisabled') ? expect(controller.addObserver.calledWith('isSharedChecked')).to.be.false:
expect(controller.addObserver.calledWith('isSharedChecked')).to.be.true;
+ });
+ it('check widgetProperties`', function () {
expect(controller.get('widgetProperties')).to.equal('widgetProperties');
+ });
+ it('check widgetValues', function () {
expect(controller.get('widgetValues')).to.equal('widgetValues');
+ });
+ it('check widgetMetrics', function () {
expect(controller.get('widgetMetrics')).to.equal('widgetMetrics');
+ });
+ it('check widgetAuthor', function () {
expect(controller.get('widgetAuthor')).to.equal('widgetAuthor');
+ });
+ it('check widgetName', function () {
expect(controller.get('widgetName')).to.equal('widgetName');
+ });
+ it('check widgetDescription', function () {
expect(controller.get('widgetDescription')).to.equal('widgetDescription');
+ });
+ it('check isSharedChecked', function () {
expect(controller.get('isSharedChecked')).to.be.true;
+ });
+ it('check isSharedCheckboxDisabled', function () {
expect(controller.get('isSharedCheckboxDisabled')).to.be.true;
});
});
@@ -92,7 +108,8 @@ describe('App.WidgetWizardStep3Controller', function () {
});
describe("#collectWidgetData()", function () {
- it("", function () {
+
+ beforeEach(function () {
controller.setProperties({
widgetName: 'widgetName',
content: Em.Object.create({widgetType: 'T1'}),
@@ -103,7 +120,11 @@ describe('App.WidgetWizardStep3Controller', function () {
widgetValues: [{computedValue: 'cv', value: 'v'}],
widgetProperties: 'widgetProperties'
});
- expect(controller.collectWidgetData()).to.eql({
+ });
+
+ it('collected widget data is valid', function () {
+ var widgetData = controller.collectWidgetData();
+ expect(widgetData).to.eql({
"WidgetInfo": {
"widget_name": "widgetName",
"widget_type": "T1",
@@ -111,14 +132,10 @@ describe('App.WidgetWizardStep3Controller', function () {
"scope": "CLUSTER",
"author": "widgetAuthor",
"metrics": [
- {
- "name": "m1"
- }
+ {"name": "m1" }
],
"values": [
- {
- "value": "v"
- }
+ { "value": "v" }
],
"properties": "widgetProperties"
}
@@ -138,7 +155,7 @@ describe('App.WidgetWizardStep3Controller', function () {
App.router.get.restore();
mock.cancel.restore();
});
- it("", function () {
+ it('cancel is called', function () {
controller.cancel();
expect(mock.cancel.calledOnce).to.be.true;
});
@@ -153,6 +170,7 @@ describe('App.WidgetWizardStep3Controller', function () {
sinon.stub(controller, 'collectWidgetData');
sinon.stub(App.router, 'get').returns(mock);
sinon.stub(App.router, 'send');
+ controller.complete();
});
afterEach(function () {
App.router.get.restore();
@@ -160,10 +178,13 @@ describe('App.WidgetWizardStep3Controller', function () {
controller.collectWidgetData.restore();
mock.finishWizard.restore();
});
- it("", function () {
- controller.complete();
+ it('widget data is collected', function () {
expect(controller.collectWidgetData.calledOnce).to.be.true;
+ });
+ it('user is moved to finish the wizard', function () {
expect(App.router.send.calledWith('complete')).to.be.true;
+ });
+ it('finishWizard is called', function () {
expect(mock.finishWizard.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/controllers/wizard/step2_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step2_test.js b/ambari-web/test/controllers/wizard/step2_test.js
index 41782bc..8869444 100644
--- a/ambari-web/test/controllers/wizard/step2_test.js
+++ b/ambari-web/test/controllers/wizard/step2_test.js
@@ -239,7 +239,7 @@ describe('App.WizardStep2Controller', function () {
describe('#sshUserError', function () {
userErrorTests.forEach(function(test) {
- it('', function() {
+ it(JSON.stringify(test), function() {
var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, sshUser: test.user}}});
if(Em.isNone(test.e)) {
expect(controller.get('sshUserError')).to.equal(null);
@@ -255,7 +255,7 @@ describe('App.WizardStep2Controller', function () {
describe('#sshPortError', function () {
userErrorTests.forEach(function(test) {
- it('', function() {
+ it(JSON.stringify(test), function() {
var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, sshPort: test.sshPort}}});
if(Em.isNone(test.e)) {
expect(controller.get('sshPortError')).to.equal(null);
@@ -574,7 +574,7 @@ describe('App.WizardStep2Controller', function () {
describe('#setAmbariJavaHome', function() {
beforeEach(function() {
- sinon.spy($, 'ajax');
+ sinon.stub($, 'ajax', Em.K);
});
afterEach(function() {
$.ajax.restore();
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 dd1e918..6262678 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -43,12 +43,16 @@ describe('App.WizardStep3Controller', function () {
sinon.stub(App.db, 'getDisplayLength', Em.K);
sinon.stub(App.db, 'getFilterConditions').returns([]);
sinon.stub(App.router, 'send', Em.K);
+ sinon.stub(App.ajax, 'send', function () {
+ return {done: Em.K}
+ });
});
afterEach(function () {
App.db.getDisplayLength.restore();
App.router.send.restore();
App.db.getFilterConditions.restore();
+ App.ajax.send.restore();
});
App.TestAliases.testAsComputedGt(getController(), 'isHostHaveWarnings', 'warnings.length', 0);
@@ -733,14 +737,6 @@ describe('App.WizardStep3Controller', function () {
describe('#doBootstrap()', function () {
- beforeEach(function () {
- sinon.spy(App.ajax, 'send');
- });
-
- afterEach(function () {
- App.ajax.send.restore();
- });
-
it('shouldn\'t do nothing if stopBootstrap is true', function () {
c.set('stopBootstrap', true);
c.doBootstrap();
@@ -783,13 +779,6 @@ describe('App.WizardStep3Controller', function () {
describe('#isHostsRegistered', function () {
- beforeEach(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
-
it('shouldn\'t do nothing if stopBootstrap is true', function () {
c.set('stopBootstrap', true);
c.isHostsRegistered();
@@ -900,14 +889,6 @@ describe('App.WizardStep3Controller', function () {
describe('#getAllRegisteredHosts', function () {
- beforeEach(function () {
- sinon.spy(App.ajax, 'send');
- });
-
- afterEach(function () {
- App.ajax.send.restore();
- });
-
it('should call App.ajax.send', function () {
c.getAllRegisteredHosts();
expect(App.ajax.send.calledOnce).to.equal(true);
@@ -1012,14 +993,6 @@ describe('App.WizardStep3Controller', function () {
describe('#getHostInfo', function () {
- beforeEach(function () {
- sinon.spy(App.ajax, 'send');
- });
-
- afterEach(function () {
- App.ajax.send.restore();
- });
-
it('should do ajax request', function () {
c.getHostInfo();
expect(App.ajax.send.calledOnce).to.equal(true);
@@ -2662,29 +2635,6 @@ describe('App.WizardStep3Controller', function () {
});
- describe('#getJDKName', function () {
-
- beforeEach(function () {
- sinon.stub($, 'ajax', Em.K);
- sinon.stub(App, 'get', function (k) {
- if ('testMode' === k) return false;
- return Em.get(App, k);
- });
- });
-
- afterEach(function () {
- $.ajax.restore();
- App.get.restore();
- });
-
- it('should do proper request to ambari-server', function () {
- c.getJDKName();
- expect($.ajax.args[0][0].type).to.contain('GET');
- expect($.ajax.args[0][0].url).to.contain('/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/jdk.name,RootServiceComponents/properties/java.home,RootServiceComponents/properties/jdk_location');
- });
-
- });
-
describe('#getJDKNameSuccessCallback', function () {
it('should set proper data to controller properties', function () {
@@ -2715,7 +2665,6 @@ describe('App.WizardStep3Controller', function () {
describe('#doCheckJDK', function () {
beforeEach(function () {
- sinon.stub($, 'ajax', Em.K);
sinon.stub(App, 'get', function (k) {
if ('testMode' === k) return false;
return Em.get(App, k);
@@ -2723,11 +2672,10 @@ describe('App.WizardStep3Controller', function () {
});
afterEach(function () {
- $.ajax.restore();
App.get.restore();
});
- it('should do proper request to the ambari-server', function () {
+ it('should do request to the ambari-server', function () {
var bootHosts = [
Em.Object.create({name: 'n1', bootStatus: 'REGISTERED'}),
@@ -2741,12 +2689,7 @@ describe('App.WizardStep3Controller', function () {
jdkLocation: jdkLocation
});
c.doCheckJDK();
- var request = $.ajax.args[0][0], data = JSON.parse(request.data);
- expect(request.type).to.equal('POST');
- expect(request.url).to.contain('/requests');
- expect(data.RequestInfo.parameters.java_home).to.equal(javaHome);
- expect(data.RequestInfo.parameters.jdk_location).to.equal(jdkLocation);
- expect(data['Requests/resource_filters'][0].hosts).to.equal('n1,n2');
+ expect(App.ajax.send.calledOnce).to.be.true;
});
});
@@ -2754,7 +2697,6 @@ describe('App.WizardStep3Controller', function () {
describe('#doCheckJDKsuccessCallback', function () {
beforeEach(function () {
- sinon.stub($, 'ajax', Em.K);
sinon.stub(App, 'get', function (k) {
if ('testMode' === k) return false;
return Em.get(App, k);
@@ -2762,7 +2704,6 @@ describe('App.WizardStep3Controller', function () {
});
afterEach(function () {
- $.ajax.restore();
App.get.restore();
});
@@ -2787,7 +2728,7 @@ describe('App.WizardStep3Controller', function () {
expect(c.get('isJDKWarningsLoaded')).to.equal(expected);
});
- it('should do proper request to ambari-server', function () {
+ it('should do request to ambari-server', function () {
var data = null,
jdkRequestIndex = 'jdkRequestIndex',
@@ -2795,8 +2736,7 @@ describe('App.WizardStep3Controller', function () {
c.set('jdkRequestIndex', jdkRequestIndex);
c.set('jdkCategoryWarnings', null);
c.doCheckJDKsuccessCallback(data);
- expect($.ajax.args[0][0].type).to.equal('GET');
- expect($.ajax.args[0][0].url).to.contain(url);
+ expect(App.ajax.send.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 fdeaf0d..d4f912d 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -76,6 +76,15 @@ describe('App.WizardStep6Controller', function () {
beforeEach(function () {
controller = getController();
+ sinon.stub(App.ajax, 'send', function () {
+ return {
+ then: Em.K
+ };
+ });
+ });
+
+ afterEach(function () {
+ App.ajax.send.restore();
});
App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController');
@@ -1311,11 +1320,6 @@ describe('App.WizardStep6Controller', function () {
}
];
});
- sinon.stub(App.ajax, 'send', function () {
- return {
- then: Em.K
- };
- });
});
afterEach(function () {
@@ -1326,7 +1330,6 @@ describe('App.WizardStep6Controller', function () {
App.get.restore();
controller.getCurrentMasterSlaveBlueprint.restore();
App.Host.find.restore();
- App.ajax.send.restore();
});
cases.forEach(function (item) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 334563d..233f785 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -109,12 +109,15 @@ function getController() {
describe('App.InstallerStep7Controller', function () {
beforeEach(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
installerStep7Controller = getController();
});
afterEach(function() {
+ App.ajax.send.restore();
App.config.setPreDefinedServiceConfigs.restore();
+ installerStep7Controller.destroy();
});
App.TestAliases.testAsComputedAlias(getController(), 'masterComponentHosts', 'content.masterComponentHosts', 'array');
@@ -421,12 +424,6 @@ describe('App.InstallerStep7Controller', function () {
});
describe('#loadInstalledServicesConfigGroups', function () {
- before(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- after(function () {
- App.ajax.send.restore();
- });
it('should do ajax request for each received service name', function () {
var serviceNames = ['s1', 's2', 's3'];
installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
@@ -435,12 +432,6 @@ describe('App.InstallerStep7Controller', function () {
});
describe('#getConfigTags', function () {
- before(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- after(function () {
- App.ajax.send.restore();
- });
it('should do ajax-request', function () {
installerStep7Controller.getConfigTags();
expect(App.ajax.send.calledOnce).to.equal(true);
@@ -476,7 +467,8 @@ describe('App.InstallerStep7Controller', function () {
describe('#checkMySQLHost', function () {
it('should send query', function () {
- expect(installerStep7Controller.checkMySQLHost().readyState).to.equal(1);
+ installerStep7Controller.checkMySQLHost();
+ expect(App.ajax.send.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 fc52920..fa57fd5 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -649,11 +649,11 @@ describe('App.InstallerStep9Controller', function () {
jsonError: true
}
]);
- tests.forEach(function (test) {
- it('', function () {
- c.reopen({hosts: test.hosts});
- c.hostHasClientsOnly(test.jsonError);
- test.hosts.forEach(function (host) {
+ tests.forEach(function (test, index1) {
+ test.hosts.forEach(function (host, index2) {
+ it('#test ' + index1 + ' #host ' + index2, function () {
+ c.reopen({hosts: test.hosts});
+ c.hostHasClientsOnly(test.jsonError);
expect(c.get('hosts').findProperty('hostName', host.hostName).get('status')).to.equal(host.e.status);
expect(c.get('hosts').findProperty('hostName', host.hostName).get('progress')).to.equal(host.e.progress);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/mixins/common/table_server_view_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/table_server_view_mixin_test.js b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
index b7b8236..b503ddf 100644
--- a/ambari-web/test/mixins/common/table_server_view_mixin_test.js
+++ b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
@@ -217,14 +217,16 @@ describe('App.MainConfigHistoryView', function() {
describe("#updaterSuccessCb()", function () {
beforeEach(function () {
sinon.stub(view, 'propertyDidChange');
+ view.set('filteringComplete', false);
+ view.updaterSuccessCb();
});
afterEach(function () {
view.propertyDidChange.restore();
});
- it("", function () {
- view.set('filteringComplete', false);
- view.updaterSuccessCb();
+ it('pageContent is forced to be recalculated', function () {
expect(view.propertyDidChange.calledWith('pageContent')).to.be.true;
+ });
+ it('filteringComplete is updated', function () {
expect(view.get('filteringComplete')).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/mixins/common/widget_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/widget_mixin_test.js b/ambari-web/test/mixins/common/widget_mixin_test.js
index 9bb7f70..1c965b8 100644
--- a/ambari-web/test/mixins/common/widget_mixin_test.js
+++ b/ambari-web/test/mixins/common/widget_mixin_test.js
@@ -84,87 +84,98 @@ describe('App.WidgetMixin', function () {
});
describe("#getRequestData()", function () {
- var mixinObject = mixinClass.create();
- it("", function () {
- var data = [
- {
- "name": "regionserver.Server.percentFilesLocal",
- "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
- "service_name": "HBASE",
- "component_name": "HBASE_REGIONSERVER"
- },
- {
- "name": "regionserver.Server.percentFilesLocal2",
- "metric_path": "w2",
- "service_name": "HBASE",
- "component_name": "HBASE_REGIONSERVER"
- },
- {
- "name": "regionserver.Server.percentFilesLocal",
- "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
- "service_name": "HBASE",
- "component_name": "HBASE_REGIONSERVER",
- "host_component_criteria": 'c1'
- },
- {
- "name": "regionserver.Server.percentFilesLocal",
- "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
- "service_name": "HDFS",
- "component_name": "DATANODE",
- "host_component_criteria": 'c1'
- }
- ];
+ var data = [
+ {
+ "name": "regionserver.Server.percentFilesLocal",
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "regionserver.Server.percentFilesLocal2",
+ "metric_path": "w2",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "regionserver.Server.percentFilesLocal",
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER",
+ "host_component_criteria": 'c1'
+ },
+ {
+ "name": "regionserver.Server.percentFilesLocal",
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
+ "service_name": "HDFS",
+ "component_name": "DATANODE",
+ "host_component_criteria": 'c1'
+ }
+ ];
+
+ beforeEach(function () {
+ this.requestData = mixinClass.create().getRequestData(data);
+ });
- expect(JSON.stringify(mixinObject.getRequestData(data))).to.eql(JSON.stringify({
- "HBASE_HBASE_REGIONSERVER": {
- "name": "regionserver.Server.percentFilesLocal",
- "service_name": "HBASE",
- "component_name": "HBASE_REGIONSERVER",
- "metric_paths": [
- {
- "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
- "metric_type": "POINT_IN_TIME",
- "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
- "context": {}
+ it('HBASE_HBASE_REGIONSERVER', function () {
+ var HBASE_HBASE_REGIONSERVER = {
+ "name": "regionserver.Server.percentFilesLocal",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER",
+ "metric_paths": [
+ {
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
+ "metric_type": "POINT_IN_TIME",
+ "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
+ "context": {}
},
- {
- "metric_path": "w2",
- "metric_type": "POINT_IN_TIME",
- "id": "w2_POINT_IN_TIME",
- "context": {}
- }
- ]
- },
- "HBASE_HBASE_REGIONSERVER_c1": {
- "name": "regionserver.Server.percentFilesLocal",
- "service_name": "HBASE",
- "component_name": "HBASE_REGIONSERVER",
- "host_component_criteria": "c1",
- "metric_paths": [
- {
- "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
- "metric_type": "POINT_IN_TIME",
- "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
- "context": {}
- }
- ]
- },
- "HDFS_DATANODE_c1": {
- "name": "regionserver.Server.percentFilesLocal",
- "service_name": "HDFS",
- "component_name": "DATANODE",
- "host_component_criteria": "c1",
- "metric_paths": [
- {
- "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
- "metric_type": "POINT_IN_TIME",
- "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
- "context": {}
+ {
+ "metric_path": "w2",
+ "metric_type": "POINT_IN_TIME",
+ "id": "w2_POINT_IN_TIME",
+ "context": {}
}
]
- }
- }));
+ };
+ expect(JSON.stringify(this.requestData['HBASE_HBASE_REGIONSERVER'])).to.equal(JSON.stringify(HBASE_HBASE_REGIONSERVER));
});
+
+ it('HBASE_HBASE_REGIONSERVER_c1', function () {
+ var HBASE_HBASE_REGIONSERVER_c1 = {
+ "name": "regionserver.Server.percentFilesLocal",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER",
+ "host_component_criteria": "c1",
+ "metric_paths": [
+ {
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
+ "metric_type": "POINT_IN_TIME",
+ "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
+ "context": {}
+ }
+ ]
+ };
+ expect(JSON.stringify(this.requestData['HBASE_HBASE_REGIONSERVER_c1'])).to.equal(JSON.stringify(HBASE_HBASE_REGIONSERVER_c1));
+ });
+
+ it('HDFS_DATANODE_c1', function () {
+ var HDFS_DATANODE_c1 = {
+ "name": "regionserver.Server.percentFilesLocal",
+ "service_name": "HDFS",
+ "component_name": "DATANODE",
+ "host_component_criteria": "c1",
+ "metric_paths": [
+ {
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
+ "metric_type": "POINT_IN_TIME",
+ "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
+ "context": {}
+ }
+ ]
+ };
+ expect(JSON.stringify(this.requestData['HDFS_DATANODE_c1'])).to.equal(JSON.stringify(HDFS_DATANODE_c1));
+ });
+
});
describe("#getServiceComponentMetrics()", function () {
@@ -175,7 +186,7 @@ describe('App.WidgetMixin', function () {
after(function () {
App.ajax.send.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
var request = {
service_name: 'S1',
component_name: 'C1',
@@ -209,7 +220,7 @@ describe('App.WidgetMixin', function () {
describe("#getMetricsSuccessCallback()", function () {
var mixinObject = mixinClass.create();
- it("", function () {
+ it("metric is mapped from provided path", function () {
var data = {
metrics: {
"hbase": {
@@ -241,7 +252,7 @@ describe('App.WidgetMixin', function () {
App.ajax.send.restore();
mixinObject.computeHostComponentCriteria.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
var request = {
component_name: 'C1',
metric_paths: [
@@ -344,18 +355,20 @@ describe('App.WidgetMixin', function () {
describe("#cloneWidget()", function () {
var mixinObject = mixinClass.create();
-
+ var popup;
before(function () {
sinon.spy(App, 'showConfirmationPopup');
sinon.stub(mixinObject, 'postWidgetDefinition', Em.K);
+ popup = mixinObject.cloneWidget();
});
after(function () {
App.showConfirmationPopup.restore();
mixinObject.postWidgetDefinition.restore();
});
- it("", function () {
- var popup = mixinObject.cloneWidget();
+ it("popup is shown", function () {
expect(App.showConfirmationPopup.calledOnce).to.be.true;
+ });
+ it('postWidgetDefinition is called', function () {
popup.onPrimary();
expect(mixinObject.postWidgetDefinition.calledOnce).to.be.true;
});
@@ -372,7 +385,7 @@ describe('App.WidgetMixin', function () {
App.ajax.send.restore();
mixinObject.collectWidgetData.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
mixinObject.postWidgetDefinition();
expect(App.ajax.send.getCall(0).args[0]).to.eql({
name: 'widgets.wizard.add',
@@ -415,7 +428,9 @@ describe('App.WidgetLoadAggregator', function () {
});
describe("#groupRequests()", function () {
- it("", function () {
+ var result;
+
+ beforeEach(function () {
var requests = [
{
startCallName: 'n1',
@@ -466,15 +481,31 @@ describe('App.WidgetLoadAggregator', function () {
})
}
];
- var result = aggregator.groupRequests(requests);
+ result = aggregator.groupRequests(requests);
+ });
+ it("result['n1_C1'].subRequests.length", function () {
expect(result['n1_C1'].subRequests.length).to.equal(1);
+ });
+ it("result['n1_C1'].data.metric_paths.length", function () {
expect(result['n1_C1'].data.metric_paths.length).to.equal(1);
+ });
+ it("result['n1_C1_graph'].subRequests.length", function () {
expect(result['n1_C1_graph'].subRequests.length).to.equal(1);
+ });
+ it("result['n1_C1_graph'].data.metric_paths.length", function () {
expect(result['n1_C1_graph'].data.metric_paths.length).to.equal(1);
+ });
+ it("result['n2_C1'].subRequests.length", function () {
expect(result['n2_C1'].subRequests.length).to.equal(1);
+ });
+ it("result['n2_C1'].data.metric_paths.length", function () {
expect(result['n2_C1'].data.metric_paths.length).to.equal(1);
+ });
+ it("result['n1_C2'].subRequests.length", function () {
expect(result['n1_C2'].subRequests.length).to.equal(1);
+ });
+ it("result['n1_C2'].data.metric_paths.length", function () {
expect(result['n1_C2'].data.metric_paths.length).to.equal(1);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/models/host_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_component_test.js b/ambari-web/test/models/host_component_test.js
index ef68fb6..4266c3c 100644
--- a/ambari-web/test/models/host_component_test.js
+++ b/ambari-web/test/models/host_component_test.js
@@ -36,53 +36,88 @@ describe('App.HostComponent', function() {
});
describe('#isClient', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.stub(App.get('components.clients'), 'contains', Em.K);
hc.propertyDidChange('isClient');
hc.get('isClient');
- expect(App.get('components.clients').contains.calledWith('COMP1')).to.be.true;
+ });
+
+ afterEach(function () {
App.get('components.clients').contains.restore();
});
+
+ it('components.clients is called with correct data', function() {
+ expect(App.get('components.clients').contains.calledWith('COMP1')).to.be.true;
+ });
});
describe('#displayName', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.stub(App.format, 'role', Em.K);
hc.propertyDidChange('displayName');
hc.get('displayName');
- expect(App.format.role.calledWith('COMP1')).to.be.true;
+ });
+
+ afterEach(function () {
App.format.role.restore();
});
+
+ it('App.format.role is called with correct data', function() {
+ expect(App.format.role.calledWith('COMP1')).to.be.true;
+ });
});
describe('#isMaster', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.stub(App.get('components.masters'), 'contains', Em.K);
hc.propertyDidChange('isMaster');
hc.get('isMaster');
- expect(App.get('components.masters').contains.calledWith('COMP1')).to.be.true;
+ });
+
+ afterEach(function () {
App.get('components.masters').contains.restore();
});
+
+ it('components.masters is called with correct data', function() {
+ expect(App.get('components.masters').contains.calledWith('COMP1')).to.be.true;
+ });
});
describe('#isSlave', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.stub(App.get('components.slaves'), 'contains', Em.K);
hc.propertyDidChange('isSlave');
hc.get('isSlave');
- expect(App.get('components.slaves').contains.calledWith('COMP1')).to.be.true;
+ });
+
+ afterEach(function () {
App.get('components.slaves').contains.restore();
});
+
+ it('components.slaves is called with correct data', function() {
+ expect(App.get('components.slaves').contains.calledWith('COMP1')).to.be.true;
+ });
});
describe('#isDeletable', function() {
- it('', function() {
+
+ beforeEach(function () {
sinon.stub(App.get('components.deletable'), 'contains', Em.K);
hc.propertyDidChange('isDeletable');
hc.get('isDeletable');
- expect(App.get('components.deletable').contains.calledWith('COMP1')).to.be.true;
+ });
+
+ afterEach(function () {
App.get('components.deletable').contains.restore();
});
+
+ it('components.deletable is called with correct data', function() {
+ expect(App.get('components.deletable').contains.calledWith('COMP1')).to.be.true;
+ });
});
App.TestAliases.testAsComputedIfThenElse(hc, 'passiveTooltip', 'isActive', '', Em.I18n.t('hosts.component.passive.mode'));
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/models/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_test.js b/ambari-web/test/models/host_test.js
index 9642c41..cbeca12 100644
--- a/ambari-web/test/models/host_test.js
+++ b/ambari-web/test/models/host_test.js
@@ -264,7 +264,7 @@ describe('App.Host', function () {
});
describe('#disksMounted', function () {
- it('', function () {
+ it('depends on diskInfo count', function () {
host1.set('diskInfo', [
{}
]);
@@ -274,7 +274,7 @@ describe('App.Host', function () {
});
describe('#coresFormatted', function () {
- it('', function () {
+ it('depends on cpu, cpuPhysical', function () {
host1.set('cpu', 1);
host1.set('cpuPhysical', 2);
host1.propertyDidChange('coresFormatted');
@@ -298,7 +298,7 @@ describe('App.Host', function () {
});
describe('#diskUsage', function () {
- it('', function () {
+ it('depends on diskTotal, diskUsed', function () {
host1.reopen({
diskUsed: 10
});
@@ -309,13 +309,20 @@ describe('App.Host', function () {
});
describe('#memoryFormatted', function () {
- it('', function () {
- host1.set('memory', 1024);
+
+ beforeEach(function () {
sinon.stub(misc, 'formatBandwidth', Em.K);
+ });
+
+ afterEach(function () {
+ misc.formatBandwidth.restore();
+ });
+
+ it('depends on memory', function () {
+ host1.set('memory', 1024);
host1.propertyDidChange('memoryFormatted');
host1.get('memoryFormatted');
expect(misc.formatBandwidth.calledWith(1048576)).to.be.true;
- misc.formatBandwidth.restore()
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/router_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/router_test.js b/ambari-web/test/router_test.js
index 864cff9..456200f 100644
--- a/ambari-web/test/router_test.js
+++ b/ambari-web/test/router_test.js
@@ -377,7 +377,7 @@ describe('App.Router', function () {
afterEach(function () {
App.ajax.send.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
router.transitionToAdminView();
expect(App.ajax.send.calledWith({
name: 'ambari.service.load_server_version',
@@ -427,7 +427,7 @@ describe('App.Router', function () {
router.transitionTo.restore();
mock.loadAmbariViews.restore();
});
- it("", function () {
+ it("transitionTo called with corrent route", function () {
router.transitionToViews();
expect(mock.loadAmbariViews.calledOnce).to.be.true;
expect(router.transitionTo.calledWith('main.views.index')).to.be.true;
@@ -441,7 +441,7 @@ describe('App.Router', function () {
afterEach(function () {
router.transitionToViews.restore();
});
- it("", function () {
+ it("transitionToViews called once", function () {
router.adminViewInfoErrorCallback();
expect(router.transitionToViews.calledOnce).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 0b4ac90..173ea5f 100644
--- a/ambari-web/test/utils/helper_test.js
+++ b/ambari-web/test/utils/helper_test.js
@@ -432,6 +432,9 @@ describe('utils/helper', function() {
});
describe("#role()", function() {
+ before(function () {
+ App.format.stackRolesMap = {};
+ });
beforeEach(function () {
sinon.stub(App.StackService, 'find').returns([Em.Object.create({
id: 'S1',
@@ -440,16 +443,19 @@ describe('utils/helper', function() {
sinon.stub(App.StackServiceComponent, 'find').returns([Em.Object.create({
id: 'C1',
displayName: 'c1'
- })])
+ })]);
});
afterEach(function () {
App.StackService.find.restore();
App.StackServiceComponent.find.restore();
});
- it("", function() {
- App.format.stackRolesMap = {};
+ it("S1 -> s1", function() {
expect(App.format.role('S1')).to.equal('s1');
+ });
+ it("C1 -> c1", function() {
expect(App.format.role('C1')).to.equal('c1');
+ });
+ it("stackRolesMap is not empty", function() {
expect(App.format.stackRolesMap).to.not.be.empty;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/utils/load_timer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/load_timer_test.js b/ambari-web/test/utils/load_timer_test.js
index 5955fc7..4e84134 100644
--- a/ambari-web/test/utils/load_timer_test.js
+++ b/ambari-web/test/utils/load_timer_test.js
@@ -36,14 +36,14 @@ describe('App.loadTimer', function () {
});
describe("#start()", function() {
- it("", function() {
+ it("time should be cached", function() {
App.loadTimer.start('test');
expect(App.loadTimer.get('timeStampCache')['test']).to.be.an('number');
});
});
describe("#finish()", function() {
- it("", function() {
+ it("timeStampCache is empty", function() {
App.loadTimer.start('test');
expect(App.loadTimer.finish('test')).to.be.not.empty;
expect(App.loadTimer.get('timeStampCache')).to.be.empty;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/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 1d4e7f4..1d07dbe 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -381,7 +381,8 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
});
describe("#groupRequests()", function () {
- it("", function () {
+ var result;
+ beforeEach(function () {
var requests = [
{
name: 'r1',
@@ -399,11 +400,18 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
fields: ['f3', 'f4']
}
];
- var result = aggregator.groupRequests(requests);
-
+ result = aggregator.groupRequests(requests);
+ });
+ it("result['r1'].subRequests.length", function () {
expect(result['r1'].subRequests.length).to.equal(1);
+ });
+ it("result['r1'].fields.length", function () {
expect(result['r1'].fields.length).to.equal(1);
+ });
+ it("result['r2'].subRequests.length", function () {
expect(result['r2'].subRequests.length).to.equal(2);
+ });
+ it("result['r2'].fields.length", function () {
expect(result['r2'].fields.length).to.equal(3);
});
});
@@ -428,7 +436,7 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
App.ajax.send.restore();
aggregator.formatRequestData.restore();
});
- it("", function () {
+ it("valid request is sent", function () {
var context = Em.Object.create({content: {hostName: 'host1'}});
var requests = {
'r1': {
@@ -458,7 +466,7 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
App.dateTime.restore();
});
- it("", function () {
+ it("data is formed", function () {
var context = Em.Object.create({timeUnitSeconds: 3600});
var request = {
name: 'r1',
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/common/configs/config_history_flow_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/config_history_flow_test.js b/ambari-web/test/views/common/configs/config_history_flow_test.js
index ab3383e..667c7a4 100644
--- a/ambari-web/test/views/common/configs/config_history_flow_test.js
+++ b/ambari-web/test/views/common/configs/config_history_flow_test.js
@@ -236,16 +236,26 @@ describe.skip('App.ConfigHistoryFlowView', function () {
});
describe('#openFullList()', function () {
- it('', function () {
- var event = {
+ var event;
+ beforeEach(function () {
+ event = {
stopPropagation: Em.K
};
sinon.spy(event, 'stopPropagation');
view.openFullList(event);
- expect(event.stopPropagation.calledOnce).to.be.true;
- expect(view.get('showFullList')).to.be.true;
+ });
+
+ afterEach(function () {
event.stopPropagation.restore();
});
+
+ it('stopPropagation is called once', function () {
+ expect(event.stopPropagation.calledOnce).to.be.true;
+ });
+
+ it('stopPropagation is true', function () {
+ expect(view.get('stopPropagation')).to.be.true;
+ });
});
describe('#hideFullList()', function () {
@@ -279,12 +289,19 @@ describe.skip('App.ConfigHistoryFlowView', function () {
});
describe('#didInsertElement()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(App, 'tooltip');
view.didInsertElement();
- expect(App.tooltip.calledOnce).to.be.true;
+ });
+
+ afterEach(function () {
App.tooltip.restore();
});
+
+ it('App.tooltip is called on�e', function () {
+ expect(App.tooltip.calledOnce).to.be.true;
+ });
});
describe('#willInsertElement()', function () {
@@ -561,28 +578,37 @@ describe.skip('App.ConfigHistoryFlowView', function () {
});
describe('#sendRevertCall()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(App.ajax, 'send', Em.K);
view.sendRevertCall(Em.Object.create());
+ });
- expect(App.ajax.send.calledOnce).to.be.true;
+ afterEach(function () {
App.ajax.send.restore();
});
+
+ it('request is sent', function () {
+ expect(App.ajax.send.calledOnce).to.be.true;
+ });
});
describe('#sendRevertCallSuccess()', function () {
beforeEach(function () {
sinon.spy(view.get('controller'), 'loadStep');
sinon.stub(App.router.get('updateController'), 'updateComponentConfig', Em.K);
+ view.sendRevertCallSuccess();
});
afterEach(function () {
view.get('controller').loadStep.restore();
App.router.get('updateController').updateComponentConfig.restore();
});
- it('', function () {
- view.sendRevertCallSuccess();
+ it('loadStep is called', function () {
expect(view.get('controller').loadStep.calledOnce).to.be.true;
+ });
+
+ it('updateComponentConfig is called', function () {
expect(App.router.get('updateController').updateComponentConfig.calledOnce).to.be.true;
});
});
@@ -629,29 +655,47 @@ describe.skip('App.ConfigHistoryFlowView', function () {
});
describe('#shiftBack()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(view, 'decrementProperty', Em.K);
sinon.stub(view, 'adjustFlowView', Em.K);
view.shiftBack();
+ });
- expect(view.decrementProperty.calledWith('startIndex')).to.be.true;
- expect(view.adjustFlowView.calledOnce).to.be.true;
+ afterEach(function () {
view.adjustFlowView.restore();
view.decrementProperty.restore();
});
+
+ it('decrementProperty is called with correct data', function () {
+ expect(view.decrementProperty.calledWith('startIndex')).to.be.true;
+ });
+
+ it('adjustFlowView is called once', function () {
+ expect(view.adjustFlowView.calledOnce).to.be.true;
+ });
});
describe('#shiftForward()', function () {
- it('', function () {
+
+ beforeEach(function () {
sinon.stub(view, 'incrementProperty', Em.K);
sinon.stub(view, 'adjustFlowView', Em.K);
view.shiftForward();
+ });
- expect(view.incrementProperty.calledWith('startIndex')).to.be.true;
- expect(view.adjustFlowView.calledOnce).to.be.true;
+ afterEach(function () {
view.adjustFlowView.restore();
view.incrementProperty.restore();
});
+
+ it('startIndex++', function () {
+ expect(view.incrementProperty.calledWith('startIndex')).to.be.true;
+ });
+
+ it('adjustFlowView is called once', function () {
+ expect(view.adjustFlowView.calledOnce).to.be.true;
+ });
});
describe('#adjustFlowView()', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js b/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
index 90c7fa0..04564a3 100644
--- a/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/time_interval_spinner_view_test.js
@@ -237,7 +237,7 @@ describe('App.TimeIntervalSpinnerView', function () {
}
}
]).forEach(function (test) {
- it('', function () {
+ it(test.e.warn + ' ' + test.e.warnMessage, function () {
view.set('config', test.config);
view.prepareContent();
view.checkErrors();
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/common/progress_bar_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/progress_bar_view_test.js b/ambari-web/test/views/common/progress_bar_view_test.js
index 14654fb..1895056 100644
--- a/ambari-web/test/views/common/progress_bar_view_test.js
+++ b/ambari-web/test/views/common/progress_bar_view_test.js
@@ -22,7 +22,7 @@ describe('App.ProgressBarView', function () {
var view = App.ProgressBarView.create();
describe("#progressWidth", function () {
- it("", function () {
+ it("depends on `progress`", function () {
view.set('progress', 1);
view.propertyDidChange('progressWidth');
expect(view.get('progressWidth')).to.equal('width:1%;');
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/common/quick_link_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/quick_link_view_test.js b/ambari-web/test/views/common/quick_link_view_test.js
index 53c64ec..1c985a1 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -45,7 +45,7 @@ describe('App.QuickViewLinks', function () {
afterEach(function () {
App.router.get.restore();
});
- it("", function () {
+ it("ambariProperties are updated", function () {
expect(quickViewLinks.get('ambariProperties')).to.eql({p: 1});
});
});
@@ -59,22 +59,32 @@ describe('App.QuickViewLinks', function () {
App.router.get.restore();
quickViewLinks.loadQuickLinksConfigurations.restore();
});
- it("", function () {
+ it("loadQuickLinksConfigurations is called once", function () {
quickViewLinks.didInsertElement();
expect(quickViewLinks.loadQuickLinksConfigurations.calledOnce).to.be.true;
});
});
describe("#willDestroyElement()", function () {
- it("", function () {
+
+ beforeEach(function () {
quickViewLinks.setProperties({
configProperties: [{}],
actualTags: [""],
quickLinks: [{}]
});
quickViewLinks.willDestroyElement();
+ });
+
+ it("configProperties empty", function () {
expect(quickViewLinks.get('configProperties')).to.be.empty;
+ });
+
+ it("actualTags empty", function () {
expect(quickViewLinks.get('actualTags')).to.be.empty;
+ });
+
+ it("quickLinks empty", function () {
expect(quickViewLinks.get('quickLinks')).to.be.empty;
});
});
@@ -128,13 +138,6 @@ describe('App.QuickViewLinks', function () {
}
});
sinon.stub(quickViewLinks, 'getQuickLinksHosts');
- });
- afterEach(function () {
- quickViewLinks.setConfigProperties.restore();
- quickViewLinks.getQuickLinksHosts.restore();
-
- });
- it("", function () {
var data = {
Clusters: {
desired_configs: {
@@ -145,11 +148,21 @@ describe('App.QuickViewLinks', function () {
}
};
quickViewLinks.loadTagsSuccess(data);
+ });
+ afterEach(function () {
+ quickViewLinks.setConfigProperties.restore();
+ quickViewLinks.getQuickLinksHosts.restore();
+ });
+ it("actualTags is valid", function () {
expect(quickViewLinks.get('actualTags')[0]).to.eql(Em.Object.create({
siteName: 'site1',
tagName: 'tag1'
}));
+ });
+ it("setConfigProperties is called once", function () {
expect(quickViewLinks.setConfigProperties.calledOnce).to.be.true;
+ });
+ it("getQuickLinksHosts is called once", function () {
expect(quickViewLinks.getQuickLinksHosts.calledOnce).to.be.true;
});
});
@@ -273,7 +286,7 @@ describe('App.QuickViewLinks', function () {
mock.getConfigsByTags.restore();
App.router.get.restore();
});
- it("", function () {
+ it("getConfigsByTags called with correct data", function () {
quickViewLinks.set('actualTags', [{siteName: 'hdfs-site'}]);
quickViewLinks.set('requiredSiteNames', ['hdfs-site']);
quickViewLinks.setConfigProperties();
@@ -282,7 +295,7 @@ describe('App.QuickViewLinks', function () {
});
describe("#setEmptyLinks()", function () {
- it("", function () {
+ it("empty links are set", function () {
quickViewLinks.setEmptyLinks();
expect(quickViewLinks.get('quickLinks')).to.eql([{
label: quickViewLinks.t('quick.links.error.label'),
@@ -293,7 +306,7 @@ describe('App.QuickViewLinks', function () {
});
describe("#processOozieHosts()", function () {
- it("", function () {
+ it("host status is valid", function () {
quickViewLinks.set('content.hostComponents', [Em.Object.create({
componentName: 'OOZIE_SERVER',
workStatus: 'STARTED',
@@ -450,7 +463,7 @@ describe('App.QuickViewLinks', function () {
afterEach(function () {
quickViewLinks.getPublicHostName.restore();
});
- it("", function () {
+ it("public_name from getPublicHostName", function () {
quickViewLinks.set('content.hostComponents', [Em.Object.create({
componentName: 'C1',
hostName: 'host1'
@@ -474,9 +487,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
+ {property:"yarn.http.policy",
+ desired:"HTTPS_ONLY",
+ site:"yarn-site"}
]
}
},
@@ -492,9 +505,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"http",
checks:[
- {property:"yarn.http.policy",
- desired:"HTTP_ONLY",
- site:"yarn-site"}
+ {property:"yarn.http.policy",
+ desired:"HTTP_ONLY",
+ site:"yarn-site"}
]
}
},
@@ -510,9 +523,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
+ {property:"yarn.http.policy",
+ desired:"HTTPS_ONLY",
+ site:"yarn-site"}
]
}
},
@@ -528,9 +541,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"http",
checks:[
- {property:"yarn.http.policy",
- desired:"HTTP_ONLY",
- site:"yarn-site"}
+ {property:"yarn.http.policy",
+ desired:"HTTP_ONLY",
+ site:"yarn-site"}
]
}
},
@@ -546,9 +559,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"HTTP_ONLY",
checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
+ {property:"yarn.http.policy",
+ desired:"HTTPS_ONLY",
+ site:"yarn-site"}
]
}
},
@@ -564,9 +577,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"HTTPS_ONLY",
checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
+ {property:"yarn.http.policy",
+ desired:"HTTPS_ONLY",
+ site:"yarn-site"}
]
}
},
@@ -584,9 +597,9 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:[
- {property:"myservice.http.policy",
- desired:"HTTPS_ONLY",
- site:"myservice-site"}
+ {property:"myservice.http.policy",
+ desired:"HTTPS_ONLY",
+ site:"myservice-site"}
]
}
},
@@ -603,23 +616,23 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:
- [
- {
- "property":"oozie.https.port",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.file",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.pass",
- "desired":"EXIST",
- "site":"oozie-site"
- }
- ]
+ [
+ {
+ "property":"oozie.https.port",
+ "desired":"EXIST",
+ "site":"oozie-site"
+ },
+ {
+ "property":"oozie.https.keystore.file",
+ "desired":"EXIST",
+ "site":"oozie-site"
+ },
+ {
+ "property":"oozie.https.keystore.pass",
+ "desired":"EXIST",
+ "site":"oozie-site"
+ }
+ ]
}
},
m: "https for oozie (checks for https passed)",
@@ -634,23 +647,23 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:
- [
- {
- "property":"oozie.https.port",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.file",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.pass",
- "desired":"EXIST",
- "site":"oozie-site"
- }
- ]
+ [
+ {
+ "property":"oozie.https.port",
+ "desired":"EXIST",
+ "site":"oozie-site"
+ },
+ {
+ "property":"oozie.https.keystore.file",
+ "desired":"EXIST",
+ "site":"oozie-site"
+ },
+ {
+ "property":"oozie.https.keystore.pass",
+ "desired":"EXIST",
+ "site":"oozie-site"
+ }
+ ]
}
},
m: "http for oozie (checks for https did not pass)",
@@ -664,13 +677,13 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:
- [
- {
- "property":"http.enabled",
- "desired":"false",
- "site":"ranger-site"
- }
- ]
+ [
+ {
+ "property":"http.enabled",
+ "desired":"false",
+ "site":"ranger-site"
+ }
+ ]
}
},
m: "https for ranger (HDP2.2, checks passed)",
@@ -683,13 +696,13 @@ describe('App.QuickViewLinks', function () {
protocol:{
type:"https",
checks:
- [
- {
- "property":"http.enabled",
- "desired":"false",
- "site":"ranger-site"
- }
- ]
+ [
+ {
+ "property":"http.enabled",
+ "desired":"false",
+ "site":"ranger-site"
+ }
+ ]
}
},
m: "http for ranger (HDP2.2, checks for https did not pass)",
@@ -699,28 +712,28 @@ describe('App.QuickViewLinks', function () {
{
serviceName: "RANGER",
configProperties:
- [
- {
- type: 'ranger-admin-site',
- properties: {'ranger.service.http.enabled': 'false', 'ranger.service.https.attrib.ssl.enabled': 'true'}
- },
- ],
+ [
+ {
+ type: 'ranger-admin-site',
+ properties: {'ranger.service.http.enabled': 'false', 'ranger.service.https.attrib.ssl.enabled': 'true'}
+ },
+ ],
quickLinksConfig: {
protocol:{
type:"https",
checks:
- [
- {
- "property":"ranger.service.http.enabled",
- "desired":"false",
- "site":"ranger-admin-site"
- },
- {
- "property":"ranger.service.https.attrib.ssl.enabled",
- "desired":"true",
- "site":"ranger-admin-site"
- }
- ]
+ [
+ {
+ "property":"ranger.service.http.enabled",
+ "desired":"false",
+ "site":"ranger-admin-site"
+ },
+ {
+ "property":"ranger.service.https.attrib.ssl.enabled",
+ "desired":"true",
+ "site":"ranger-admin-site"
+ }
+ ]
}
},
@@ -730,28 +743,28 @@ describe('App.QuickViewLinks', function () {
{
serviceName: "RANGER",
configProperties:
- [
- {
- type: 'ranger-admin-site',
- properties: {'ranger.service.http.enabled': 'true', 'ranger.service.https.attrib.ssl.enabled': 'false'}
- },
- ],
+ [
+ {
+ type: 'ranger-admin-site',
+ properties: {'ranger.service.http.enabled': 'true', 'ranger.service.https.attrib.ssl.enabled': 'false'}
+ },
+ ],
quickLinksConfig: {
protocol:{
type:"https",
checks:
- [
- {
- "property":"ranger.service.http.enabled",
- "desired":"false",
- "site":"ranger-admin-site"
- },
- {
- "property":"ranger.service.https.attrib.ssl.enabled",
- "desired":"true",
- "site":"ranger-admin-site"
- }
- ]
+ [
+ {
+ "property":"ranger.service.http.enabled",
+ "desired":"false",
+ "site":"ranger-admin-site"
+ },
+ {
+ "property":"ranger.service.https.attrib.ssl.enabled",
+ "desired":"true",
+ "site":"ranger-admin-site"
+ }
+ ]
}
},
m: "http for ranger (HDP2.3, checks for https did not pass)",
@@ -780,13 +793,13 @@ describe('App.QuickViewLinks', function () {
'site':'yarn-site'
},
'configProperties':
- [
- {
- 'type': 'yarn-site',
- 'properties': {'yarn.timeline-service.webapp.address': 'c6401.ambari.apache.org:8188'}
- },
- ],
- 'result': '8188',
+ [
+ {
+ 'type': 'yarn-site',
+ 'properties': {'yarn.timeline-service.webapp.address': 'c6401.ambari.apache.org:8188'}
+ },
+ ],
+ 'result': '8188'
}),
Em.Object.create({
@@ -800,13 +813,13 @@ describe('App.QuickViewLinks', function () {
'site':'yarn-site'
},
'configProperties':
- [
- {
- 'type': 'yarn-site',
- 'properties': {'yarn.timeline-service.webapp.https.address': 'c6401.ambari.apache.org:8090'}
- },
- ],
- 'result': '8090',
+ [
+ {
+ 'type': 'yarn-site',
+ 'properties': {'yarn.timeline-service.webapp.https.address': 'c6401.ambari.apache.org:8090'}
+ },
+ ],
+ 'result': '8090'
})
];
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/highAvailability/nameNode/step3_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/highAvailability/nameNode/step3_view_test.js b/ambari-web/test/views/main/admin/highAvailability/nameNode/step3_view_test.js
index a8870e2..8e42df0 100644
--- a/ambari-web/test/views/main/admin/highAvailability/nameNode/step3_view_test.js
+++ b/ambari-web/test/views/main/admin/highAvailability/nameNode/step3_view_test.js
@@ -42,7 +42,7 @@ describe('App.HighAvailabilityWizardStep3View', function () {
});
describe("#curNameNode", function() {
- it("", function() {
+ it("curNameNode is get from `masterComponentHosts`", function() {
view.set('controller.content.masterComponentHosts', [{
component: 'NAMENODE',
isInstalled: true,
@@ -54,7 +54,7 @@ describe('App.HighAvailabilityWizardStep3View', function () {
});
describe("#addNameNode", function() {
- it("", function() {
+ it("addNameNode is get from `masterComponentHosts`", function() {
view.set('controller.content.masterComponentHosts', [{
component: 'NAMENODE',
isInstalled: false,
@@ -66,7 +66,7 @@ describe('App.HighAvailabilityWizardStep3View', function () {
});
describe("#secondaryNameNode", function() {
- it("", function() {
+ it("secondaryNameNode is get from `masterComponentHosts`", function() {
view.set('controller.content.masterComponentHosts', [{
component: 'SECONDARY_NAMENODE',
hostName: 'host1'
@@ -77,7 +77,7 @@ describe('App.HighAvailabilityWizardStep3View', function () {
});
describe("#journalNodes", function() {
- it("", function() {
+ it("journalNodes is get from `masterComponentHosts`", function() {
view.set('controller.content.masterComponentHosts', [{
component: 'JOURNALNODE',
hostName: 'host1'
http://git-wip-us.apache.org/repos/asf/ambari/blob/1901b395/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js b/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js
index c3202f6..b65894e 100644
--- a/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js
+++ b/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js
@@ -42,7 +42,7 @@ describe('App.HighAvailabilityWizardStep4View', function () {
});
describe("#step4BodyText", function() {
- it("", function() {
+ it("formatted with dependent data", function() {
view.set('controller.content.masterComponentHosts', [{
component: 'NAMENODE',
isInstalled: true,