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/10 15:14:12 UTC
[1/5] ambari git commit: AMBARI-14297. Apply common tests for
Em.computed macros (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk df4bbdd85 -> 8750537a3
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
index b598f6b..1f95076 100644
--- a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
@@ -21,6 +21,10 @@ var App = require('app');
require('views/main/dashboard/widget');
require('views/main/dashboard/widgets/text_widget');
+function getView() {
+ return App.TextDashboardWidgetView.create({thresh1:40, thresh2:70});
+}
+
describe('App.TextDashboardWidgetView', function() {
var tests = [
@@ -81,4 +85,8 @@ describe('App.TextDashboardWidgetView', function() {
});
});
+ App.TestAliases.testAsComputedGtProperties(getView(), 'isGreen', 'data', 'thresh2');
+
+ App.TestAliases.testAsComputedLteProperties(getView(), 'isRed', 'data', 'thresh1');
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/host/details/host_component_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_view_test.js b/ambari-web/test/views/main/host/details/host_component_view_test.js
index c1ad6aa..e8366bd 100644
--- a/ambari-web/test/views/main/host/details/host_component_view_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_view_test.js
@@ -22,20 +22,26 @@ require('views/main/host/details/host_component_view');
var hostComponentView;
+function getView() {
+ return App.HostComponentView.create({
+ startBlinking: function(){},
+ doBlinking: function(){},
+ getDesiredAdminState: function(){return $.ajax({});},
+ content: Em.Object.create({
+ componentName: 'component'
+ }),
+ hostComponent: Em.Object.create()
+ });
+}
+
describe('App.HostComponentView', function() {
beforeEach(function() {
- hostComponentView = App.HostComponentView.create({
- startBlinking: function(){},
- doBlinking: function(){},
- getDesiredAdminState: function(){return $.ajax({});},
- content: Em.Object.create({
- componentName: 'component'
- }),
- hostComponent: Em.Object.create()
- });
+ hostComponentView = getView();
});
+ App.TestAliases.testAsComputedNotEqual(getView(), 'isRestartComponentDisabled', 'workStatus', App.HostComponentStatus.started);
+
describe('#disabled', function() {
var tests = Em.A([
@@ -80,150 +86,25 @@ describe('App.HostComponentView', function() {
});
- describe('#isUpgradeFailed', function() {
-
- var tests = ['UPGRADE_FAILED'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isUpgradeFailed')).to.equal(e);
- });
- });
-
- });
-
- describe('#isInstallFailed', function() {
-
- var tests = ['INSTALL_FAILED'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isInstallFailed')).to.equal(e);
- });
- });
-
- });
-
- describe('#isStart', function() {
-
- var tests = ['STARTED','STARTING'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isStart')).to.equal(e);
- });
- });
-
- });
-
- describe('#isStop', function() {
-
- var tests = ['INSTALLED'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isStop')).to.equal(e);
- });
- });
-
- });
-
- describe('#isInstalling', function() {
-
- var tests = ['INSTALLING'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isInstalling')).to.equal(e);
- });
- });
-
- });
-
- describe('#isInit', function() {
-
- var tests = ['INIT'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isInit')).to.equal(e);
- });
- });
-
- });
-
- describe('#noActionAvailable', function() {
+ App.TestAliases.testAsComputedEqual(getView(), 'isUpgradeFailed', 'workStatus', App.HostComponentStatus.upgrade_failed);
- var tests = ['STARTING', 'STOPPING', 'UNKNOWN', 'DISABLED'];
- var testE = 'hidden';
- var defaultE = '';
+ App.TestAliases.testAsComputedEqual(getView(), 'isInstallFailed', 'workStatus', App.HostComponentStatus.install_failed);
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('noActionAvailable')).to.equal(e);
- });
- });
-
- });
+ App.TestAliases.testAsComputedEqual(getView(), 'isStop', 'workStatus', App.HostComponentStatus.stopped);
- describe('#isActive', function() {
+ App.TestAliases.testAsComputedEqual(getView(), 'isInstalling', 'workStatus', App.HostComponentStatus.installing);
- var tests = Em.A([
- {passiveState: 'OFF', e: true},
- {passiveState: 'ON', e: false},
- {passiveState: 'IMPLIED', e: false}
- ]);
-
- tests.forEach(function(test) {
- it(test.workStatus, function() {
- hostComponentView.get('content').set('passiveState', test.passiveState);
- expect(hostComponentView.get('isActive')).to.equal(test.e);
- });
- });
+ App.TestAliases.testAsComputedEqual(getView(), 'isInit', 'workStatus', App.HostComponentStatus.init);
- });
+ App.TestAliases.testAsComputedExistsIn(getView(), 'isInProgress', 'workStatus', [App.HostComponentStatus.stopping, App.HostComponentStatus.starting]);
- describe('#isRestartComponentDisabled', function() {
+ App.TestAliases.testAsComputedExistsIn(getView(), 'withoutActions', 'workStatus', [App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.unknown, App.HostComponentStatus.disabled]);
- var tests = ['STARTED'];
- var testE = false;
- var defaultE = true;
+ App.TestAliases.testAsComputedExistsIn(getView(), 'isStart', 'workStatus', [App.HostComponentStatus.started, App.HostComponentStatus.starting]);
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isRestartComponentDisabled')).to.equal(e);
- });
- });
+ App.TestAliases.testAsComputedIfThenElse(getView(), 'noActionAvailable', 'withoutActions', 'hidden', '');
- });
+ App.TestAliases.testAsComputedEqual(getView(), 'isActive', 'content.passiveState', 'OFF');
describe('#isDeleteComponentDisabled', function() {
@@ -371,22 +252,6 @@ describe('App.HostComponentView', function() {
});
- describe('#isInProgress', function() {
-
- var tests = ['STOPPING', 'STARTING'];
- var testE = true;
- var defaultE = false;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isInProgress')).to.equal(e);
- });
- });
-
- });
-
describe('#statusIconClass', function() {
var tests = Em.A([
{s: 'health-status-started', e: App.healthIconClassGreen},
@@ -634,16 +499,4 @@ describe('App.HostComponentView', function() {
});
});
- describe("#isRestartComponentDisabled", function() {
- it("component is restartable", function() {
- hostComponentView.get('hostComponent').set('workStatus', 'STARTED');
- hostComponentView.propertyDidChange('isRestartComponentDisabled');
- expect(hostComponentView.get('isRestartComponentDisabled')).to.be.false;
- });
- it("component is not restartable", function() {
- hostComponentView.get('hostComponent').set('workStatus', 'INSTALLED');
- hostComponentView.propertyDidChange('isRestartComponentDisabled');
- expect(hostComponentView.get('isRestartComponentDisabled')).to.be.true;
- });
- });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host_test.js b/ambari-web/test/views/main/host_test.js
index 22954ff..6bb3462 100644
--- a/ambari-web/test/views/main/host_test.js
+++ b/ambari-web/test/views/main/host_test.js
@@ -20,16 +20,22 @@
var App = require('app');
require('views/main/host');
+function getView() {
+ return App.MainHostView.create({
+ controller: App.MainHostController.create()
+ });
+}
+
describe('App.MainHostView', function () {
var view;
beforeEach(function () {
- view = App.MainHostView.create({
- controller: App.MainHostController.create()
- });
+ view = getView();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'colPropAssoc', 'controller.colPropAssoc', 'array');
+
describe('#didInsertElement', function () {
var cases = [
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/service/info/summary_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/summary_test.js b/ambari-web/test/views/main/service/info/summary_test.js
index 1db8c1a..66db774 100644
--- a/ambari-web/test/views/main/service/info/summary_test.js
+++ b/ambari-web/test/views/main/service/info/summary_test.js
@@ -37,6 +37,14 @@ describe('App.MainServiceInfoSummaryView', function() {
service: Em.Object.create()
});
+ App.TestAliases.testAsComputedAlias(view, 'servicesHaveClients', 'App.services.hasClient', 'boolean');
+
+ App.TestAliases.testAsComputedAlias(view, 'serviceName', 'service.serviceName', 'string');
+
+ App.TestAliases.testAsComputedAlias(view, 'alertsCount', 'controller.content.alertsCount', 'number');
+
+ App.TestAliases.testAsComputedAlias(view, 'hasCriticalAlerts', 'controller.content.hasCriticalAlerts', 'boolean');
+
describe('#servers', function () {
it('services shouldn\'t have servers except FLUME and ZOOKEEPER', function () {
expect(view.get('servers')).to.be.empty;
@@ -443,4 +451,5 @@ describe('App.MainServiceInfoSummaryView', function() {
App.router.get.restore();
});
});
+
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/item_test.js b/ambari-web/test/views/main/service/item_test.js
index 560760a..8319699 100644
--- a/ambari-web/test/views/main/service/item_test.js
+++ b/ambari-web/test/views/main/service/item_test.js
@@ -21,8 +21,22 @@ require('views/main/service/item');
var view;
+function getView() {
+ return App.MainServiceItemView.create({
+ controller: Em.Object.create({
+ content: Em.Object.create({
+ hostComponents: []
+ })
+ })
+ });
+}
+
describe('App.MainServiceItemView', function () {
+ App.TestAliases.testAsComputedAlias(getView(), 'serviceName', 'controller.content.serviceName', 'string');
+
+ App.TestAliases.testAsComputedAlias(getView(), 'displayName', 'controller.content.displayName', 'string');
+
describe('#mastersExcludedCommands', function () {
view = App.MainServiceItemView.create({
@@ -564,5 +578,6 @@ describe('App.MainServiceItemView', function () {
expect(view.get('isMaintenanceSet')).to.be.false;
});
});
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/wizard/step1_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step1_view_test.js b/ambari-web/test/views/wizard/step1_view_test.js
index 76491a5..a470495 100644
--- a/ambari-web/test/views/wizard/step1_view_test.js
+++ b/ambari-web/test/views/wizard/step1_view_test.js
@@ -22,6 +22,10 @@ require('views/wizard/step1_view');
var view;
var controller;
+function getView() {
+ return App.WizardStep1View.create();
+}
+
describe('App.WizardStep1View', function () {
describe('#operatingSystems', function () {
@@ -204,42 +208,7 @@ describe('App.WizardStep1View', function () {
});
});
- describe('#isNoOsChecked', function () {
- view = App.WizardStep1View.create();
-
- var tests = Em.A([
- {
- operatingSystems: [
- {'isSelected': false},
- {'isSelected': false}
- ],
- e: true
- },
- {
- operatingSystems: [
- {'isSelected': true},
- {'isSelected': false}
- ],
- e: false
- },
- {
- operatingSystems: [
- {'isSelected': true},
- {'isSelected': true}
- ],
- e: false
- }
- ]);
-
- tests.forEach(function (test) {
- it(test.operatingSystems.mapProperty('isSelected').join(', '), function () {
- var operatingSystems = view.get('operatingSystems');
- Ember.set(operatingSystems[0], 'isSelected', test.operatingSystems[0].isSelected);
- Ember.set(operatingSystems[1], 'isSelected', test.operatingSystems[1].isSelected);
- expect(view.get('isNoOsChecked')).to.equal(test.e);
- });
- });
- });
+ App.TestAliases.testAsComputedEveryBy(getView(), 'isNoOsChecked', 'operatingSystems', 'isSelected', false);
describe('#stacks', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/wizard/step2_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step2_view_test.js b/ambari-web/test/views/wizard/step2_view_test.js
index fc8f79f..0a74566 100644
--- a/ambari-web/test/views/wizard/step2_view_test.js
+++ b/ambari-web/test/views/wizard/step2_view_test.js
@@ -23,20 +23,17 @@ var view, controller = Em.Object.create({
clusterNameError: ''
});
+function getView() {
+ return App.WizardStep2View.create({'controller': controller});
+}
+
describe('App.WizardStep0View', function () {
beforeEach(function() {
- view = App.WizardStep2View.create({'controller': controller});
+ view = getView();
});
- describe('#sshKeyState', function() {
- it('should be equal to controller.content.installOptions.manualInstall', function() {
- controller.set('content', {installOptions: {manualInstall: false}});
- expect(view.get('sshKeyState')).to.equal(false);
- controller.toggleProperty('content.installOptions.manualInstall');
- expect(view.get('sshKeyState')).to.equal(true);
- });
- });
+ App.TestAliases.testAsComputedAlias(getView(), 'sshKeyState', 'controller.content.installOptions.manualInstall', 'string');
describe('#didInsertElement', function() {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/wizard/step3/hostLogPopupBody_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step3/hostLogPopupBody_view_test.js b/ambari-web/test/views/wizard/step3/hostLogPopupBody_view_test.js
index 2275a6c..8c0b8b3 100644
--- a/ambari-web/test/views/wizard/step3/hostLogPopupBody_view_test.js
+++ b/ambari-web/test/views/wizard/step3/hostLogPopupBody_view_test.js
@@ -19,14 +19,19 @@
var App = require('app');
require('views/wizard/step3/hostLogPopupBody_view');
var view;
+
+function getView() {
+ return App.WizardStep3HostLogPopupBody.create({
+ parentView: Em.Object.create({
+ host: Em.Object.create()
+ })
+ });
+}
+
describe('App.WizardStep3HostLogPopupBody', function() {
beforeEach(function() {
- view = App.WizardStep3HostLogPopupBody.create({
- parentView: Em.Object.create({
- host: Em.Object.create()
- })
- });
+ view = getView();
});
describe('#textArea', function() {
@@ -47,12 +52,7 @@ describe('App.WizardStep3HostLogPopupBody', function() {
});
- describe('#bootLog', function() {
- it('should be equal to parentView.host.bootLog', function() {
- var log = 'i wanna play a game';
- view.set('parentView.host.bootLog', log);
- expect(view.get('bootLog')).to.equal(log);
- });
- });
+ App.TestAliases.testAsComputedAlias(getView(), 'bootLog', 'parentView.host.bootLog', 'string');
+
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js b/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
index 3cd53a0..d49cb7a 100644
--- a/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
+++ b/ambari-web/test/views/wizard/step3/hostWarningPopupBody_view_test.js
@@ -21,19 +21,27 @@ var lazyloading = require('utils/lazy_loading');
require('views/wizard/step3/hostWarningPopupBody_view');
var view;
+function getView() {
+ return App.WizardStep3HostWarningPopupBody.create({
+ didInsertElement: Em.K,
+ $: function() {
+ return Em.Object.create({
+ toggle: Em.K
+ })
+ }
+ });
+}
+
describe('App.WizardStep3HostWarningPopupBody', function() {
beforeEach(function() {
- view = App.WizardStep3HostWarningPopupBody.create({
- didInsertElement: Em.K,
- $: function() {
- return Em.Object.create({
- toggle: Em.K
- })
- }
- });
+ view = getView();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'warningsByHost', 'bodyController.warningsByHost', 'array');
+
+ App.TestAliases.testAsComputedAlias(getView(), 'warnings', 'bodyController.warnings', 'array');
+
describe('#onToggleBlock', function() {
it('should toggle', function() {
var context = Em.Object.create({isCollapsed: false});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 199c24e..9beca51 100644
--- a/ambari-web/test/views/wizard/step6_view_test.js
+++ b/ambari-web/test/views/wizard/step6_view_test.js
@@ -23,14 +23,20 @@ require('utils/string_utils');
require('views/wizard/step6_view');
var view;
+function getView() {
+ return App.WizardStep6View.create({
+ controller: App.WizardStep6Controller.create()
+ });
+}
+
describe('App.WizardStep6View', function() {
beforeEach(function() {
- view = App.WizardStep6View.create({
- controller: App.WizardStep6Controller.create()
- });
+ view = getView();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'filteredContent', 'content', 'array');
+
describe('#content', function() {
it('should be same to controller.hosts', function() {
view.set('content', []);
@@ -40,15 +46,6 @@ describe('App.WizardStep6View', function() {
});
});
- describe('#filteredContent', function() {
- it('should be same to content', function() {
- view.set('content', []);
- var d = [{}, {}];
- view.set('controller.hosts', d);
- expect(view.get('filteredContent')).to.eql(d);
- });
- });
-
describe('#didInsertElement', function() {
beforeEach(function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/wizard/step9/hostLogPopupBody_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step9/hostLogPopupBody_view_test.js b/ambari-web/test/views/wizard/step9/hostLogPopupBody_view_test.js
index c039c0a..24cac78 100644
--- a/ambari-web/test/views/wizard/step9/hostLogPopupBody_view_test.js
+++ b/ambari-web/test/views/wizard/step9/hostLogPopupBody_view_test.js
@@ -20,16 +20,22 @@ var App = require('app');
require('views/wizard/step9/hostLogPopupBody_view');
var view;
+function getView() {
+ return App.WizardStep9HostLogPopupBodyView.create({
+ parentView: Em.Object.create({
+ host: Em.Object.create()
+ })
+ });
+}
+
describe('App.WizardStep9HostLogPopupBodyView', function() {
beforeEach(function() {
- view = App.WizardStep9HostLogPopupBodyView.create({
- parentView: Em.Object.create({
- host: Em.Object.create()
- })
- });
+ view = getView();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'isNoTasksScheduled', 'parentView.host.isNoTasksForInstall', 'boolean');
+
describe('#isHeartbeatLost', function() {
it('should depends on parentView.host.status', function() {
view.set('parentView.host.status', 'success');
@@ -39,15 +45,6 @@ describe('App.WizardStep9HostLogPopupBodyView', function() {
});
});
- describe('#isNoTasksScheduled', function() {
- it('should be same to parentView.host.isNoTasksForInstall', function() {
- view.set('parentView.host.isNoTasksForInstall', true);
- expect(view.get('isNoTasksScheduled')).to.equal(true);
- view.set('parentView.host.isNoTasksForInstall', false);
- expect(view.get('isNoTasksScheduled')).to.equal(false);
- });
- });
-
describe('#visibleTasks', function() {
Em.A([
{
[5/5] ambari git commit: AMBARI-14319. Add common tests for
Em.computed macros (2) (onechiporenko)
Posted by on...@apache.org.
AMBARI-14319. Add common tests for Em.computed macros (2) (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8750537a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8750537a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8750537a
Branch: refs/heads/trunk
Commit: 8750537a335f1975bdee53ff229b6a7a2cb07a4d
Parents: 4330659
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Dec 10 16:07:57 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Dec 10 16:07:57 2015 +0200
----------------------------------------------------------------------
.../widgets/hbase_regions_in_transition.js | 4 +-
.../views/main/dashboard/widgets/text_widget.js | 4 +-
ambari-web/test/aliases/computed/and.js | 75 ++++++++++
ambari-web/test/aliases/computed/or.js | 76 ++++++++++
ambari-web/test/controllers/application_test.js | 31 ++--
.../global/cluster_controller_test.js | 4 +
.../global/update_controller_test.js | 2 +
.../controllers/main/admin/kerberos_test.js | 2 +
.../definitions_configs_controller_test.js | 16 +-
.../definitions_details_controller_test.js | 12 ++
...anage_alert_notifications_controller_test.js | 25 +++-
.../main/service/info/summary_test.js | 6 +
.../widgets/create/step3_controller_test.js | 23 +--
.../test/controllers/wizard/step2_test.js | 42 +-----
.../test/controllers/wizard/step3_test.js | 2 +
.../test/controllers/wizard/step6_test.js | 52 +------
.../test/controllers/wizard/step7_test.js | 2 +
ambari-web/test/init_computed_aliases.js | 31 +++-
.../test/models/alerts/alert_definition_test.js | 10 +-
.../objects/service_config_property_test.js | 2 +
.../configs/service_config_version_test.js | 41 +-----
.../test/models/configs/sub_section_test.js | 14 +-
.../test/models/stack_service_component_test.js | 2 +
.../configs/widgets/config_widget_view_test.js | 27 ++--
.../common/form/spinner_input_view_test.js | 9 +-
.../stack_upgrade/upgrade_task_view_test.js | 29 +---
.../stack_upgrade/upgrade_wizard_view_test.js | 32 +---
.../main/alerts/definition_details_view_test.js | 23 ++-
.../widgets/hbase_regions_in_transition_test.js | 2 +
.../widgets/node_managers_live_test.js | 82 +----------
.../main/dashboard/widgets/text_widget_test.js | 2 +
ambari-web/test/views/wizard/step1_view_test.js | 147 +------------------
32 files changed, 354 insertions(+), 477 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js b/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js
index 3c22a5c..18902b5 100644
--- a/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js
+++ b/ambari-web/app/views/main/dashboard/widgets/hbase_regions_in_transition.js
@@ -33,10 +33,8 @@ App.HBaseRegionsInTransitionView = App.TextDashboardWidgetView.extend({
classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
isGreen: Em.computed.lteProperties('data', 'thresh1'),
- isNotGreen: Em.computed.not('isGreen'),
isRed: Em.computed.gtProperties('data', 'thresh2'),
- isNotRed: Em.computed.not('isRed'),
- isOrange: Em.computed.and('isNotGreen', 'isNotRed'),
+ isOrange: Em.computed.and('!isGreen', '!isRed'),
isNA: function () {
return this.get('data') === null;
}.property('data'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/app/views/main/dashboard/widgets/text_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/text_widget.js b/ambari-web/app/views/main/dashboard/widgets/text_widget.js
index 4389cb3..6d257a1 100644
--- a/ambari-web/app/views/main/dashboard/widgets/text_widget.js
+++ b/ambari-web/app/views/main/dashboard/widgets/text_widget.js
@@ -26,10 +26,8 @@ App.TextDashboardWidgetView = App.DashboardWidgetView.extend({
classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
isRed: Em.computed.lteProperties('data', 'thresh1'),
- isNotRed: Em.computed.not('isRed'),
- isOrange: Em.computed.and('isNotGreen', 'isNotRed'),
+ isOrange: Em.computed.and('!isGreen', '!isRed'),
isGreen: Em.computed.gtProperties('data', 'thresh2'),
- isNotGreen: Em.computed.not('isGreen'),
isNA: function () {
return this.get('data') === null;
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/aliases/computed/and.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/and.js b/ambari-web/test/aliases/computed/and.js
new file mode 100644
index 0000000..1e6ddf4
--- /dev/null
+++ b/ambari-web/test/aliases/computed/and.js
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var objectUtils = require('utils/object_utils');
+
+var helpers = App.TestAliases.helpers;
+
+function getTrulyCombination(dependentKeys) {
+ var hash = {};
+ dependentKeys.forEach(function (key) {
+ if (key.startsWith('!')) {
+ hash[key.substr(1)] = false;
+ }
+ else {
+ hash[key] = true;
+ }
+ });
+ return hash;
+}
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string[]} dependentKeys
+ */
+App.TestAliases.testAsComputedAnd = function (context, propertyName, dependentKeys) {
+
+ var realKeys = dependentKeys.map(function (key) {
+ return key.startsWith('!') ? key.substr(1) : key;
+ });
+ var trulyCombination = getTrulyCombination(dependentKeys);
+ var binaryCombos = helpers.getBinaryCombos(realKeys);
+
+ describe('#' + propertyName + ' as Em.computed.and', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql(realKeys);
+ });
+
+ binaryCombos.forEach(function (combo) {
+
+ var expectedResult = objectUtils.deepEqual(trulyCombination, combo);
+
+ it('`' + expectedResult + '` for ' + JSON.stringify(combo), function() {
+ helpers.smartStubGet(context, combo)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(expectedResult);
+ });
+
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/aliases/computed/or.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/or.js b/ambari-web/test/aliases/computed/or.js
new file mode 100644
index 0000000..8bf25c5
--- /dev/null
+++ b/ambari-web/test/aliases/computed/or.js
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var objectUtils = require('utils/object_utils');
+
+var helpers = App.TestAliases.helpers;
+
+function getFalsyCombination(dependentKeys) {
+ var hash = {};
+ dependentKeys.forEach(function (key) {
+ if (key.startsWith('!')) {
+ hash[key.substr(1)] = true;
+ }
+ else {
+ hash[key] = false;
+ }
+ });
+ return hash;
+}
+
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string[]} dependentKeys
+ */
+App.TestAliases.testAsComputedOr = function (context, propertyName, dependentKeys) {
+
+ var realKeys = dependentKeys.map(function (key) {
+ return key.startsWith('!') ? key.substr(1) : key;
+ });
+ var falsyCombination = getFalsyCombination(dependentKeys);
+ var binaryCombos = helpers.getBinaryCombos(realKeys);
+
+ describe('#' + propertyName + ' as Em.computed.or', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql(realKeys);
+ });
+
+ binaryCombos.forEach(function (combo) {
+
+ var expectedResult = !objectUtils.deepEqual(falsyCombination, combo);
+
+ it('`' + expectedResult + '` for ' + JSON.stringify(combo), function() {
+ helpers.smartStubGet(context, combo)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(expectedResult);
+ });
+
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/controllers/application_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/application_test.js b/ambari-web/test/controllers/application_test.js
index dbe5a96..efe5103 100644
--- a/ambari-web/test/controllers/application_test.js
+++ b/ambari-web/test/controllers/application_test.js
@@ -20,9 +20,17 @@
var App = require('app');
require('models/cluster');
+function getController() {
+ return App.ApplicationController.create();
+}
+
describe('App.ApplicationController', function () {
- var applicationController = App.ApplicationController.create();
+ var applicationController = getController();
+
+ App.TestAliases.testAsComputedAnd(getController(), 'isClusterDataLoaded', ['App.router.clusterController.isLoaded','App.router.loggedIn']);
+
+ App.TestAliases.testAsComputedAnd(getController(), 'isExistingClusterDataLoaded', ['App.router.clusterInstallCompleted','isClusterDataLoaded']);
describe('#showAboutPopup', function() {
var dataToShowRes = {};
@@ -109,25 +117,4 @@ describe('App.ApplicationController', function () {
});
});
- describe('#clusterDisplayName', function() {
- it ('Should return cluster display name', function() {
- applicationController.set('clusterName', '');
- expect(applicationController.get('clusterDisplayName')).to.equal('mycluster');
- });
- });
-
- describe('#isClusterDataLoaded', function() {
- beforeEach(function () {
- var stub = sinon.stub(App, 'get');
- stub.withArgs('router.clusterController.isLoaded').returns(true);
- stub.withArgs('router.loggedIn').returns(true);
- });
- afterEach(function () {
- App.get.restore();
- });
- it ('Should return true, when data loaded', function() {
- expect(applicationController.get('isClusterDataLoaded')).to.be.true;
- });
- });
-
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index 2b01ea0..c2f3498 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -35,6 +35,10 @@ describe('App.clusterController', function () {
{service_name: 'GANGLIA'}
];
+ App.TestAliases.testAsComputedAnd(controller, 'isHostContentLoaded', ['isHostsLoaded', 'isComponentsStateLoaded']);
+
+ App.TestAliases.testAsComputedAnd(controller, 'isServiceContentFullyLoaded', ['isServiceMetricsLoaded', 'isComponentsStateLoaded', 'isComponentsConfigLoaded']);
+
App.TestAliases.testAsComputedAlias(controller, 'clusterName', 'App.clusterName', 'string');
describe('#updateLoadStatus()', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 fc29aa0..482e58c 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -30,6 +30,8 @@ describe('App.UpdateController', function () {
App.TestAliases.testAsComputedAlias(App.UpdateController.create(), 'clusterName', 'App.router.clusterController.clusterName', 'string');
+ App.TestAliases.testAsComputedAnd(App.UpdateController.create(), 'updateAlertInstances', ['isWorking', '!App.router.mainAlertInstancesController.isUpdating']);
+
describe('#getUrl()', function () {
it('testMode = true', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 8130941..4b58069 100644
--- a/ambari-web/test/controllers/main/admin/kerberos_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos_test.js
@@ -26,6 +26,8 @@ describe('App.MainAdminKerberosController', function() {
App.TestAliases.testAsComputedSomeBy(controller, 'isPropertiesChanged', 'stepConfigs', 'isPropertiesChanged', true);
+ App.TestAliases.testAsComputedOr(controller, 'isSaveButtonDisabled', ['isSubmitDisabled', '!isPropertiesChanged']);
+
describe('#prepareConfigProperties', function() {
beforeEach(function() {
sinon.stub(App.Service, 'find').returns([
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 ac06de7..097fc00 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
@@ -20,16 +20,22 @@ var App = require('app');
var controller;
+function getController() {
+ return App.MainAlertDefinitionConfigsController.create({
+ allServices: ['service1', 'service2', 'service3'],
+ allComponents: ['component1', 'component2', 'component3'],
+ aggregateAlertNames: ['alertDefinitionName', 'alertDefinitionName2', 'alertDefinitionName3']
+ });
+}
+
describe('App.MainAlertDefinitionConfigsController', function () {
beforeEach(function () {
- controller = App.MainAlertDefinitionConfigsController.create({
- allServices: ['service1', 'service2', 'service3'],
- allComponents: ['component1', 'component2', 'component3'],
- aggregateAlertNames: ['alertDefinitionName', 'alertDefinitionName2', 'alertDefinitionName3']
- });
+ controller = getController();
});
+ App.TestAliases.testAsComputedOr(getController(), 'hasErrors', ['someConfigIsInvalid', 'hasThresholdsError']);
+
describe('#renderConfigs()', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
index 7b56068..2eb91c8 100644
--- a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
@@ -36,6 +36,18 @@ describe('App.MainAlertDefinitionDetailsController', function () {
App.TestAliases.testAsComputedMapBy(getController(), 'groupsList', 'content.groups', 'displayName');
+ App.TestAliases.testAsComputedOr(getController(), 'isEditing', ['editing.label.isEditing', 'App.router.mainAlertDefinitionConfigsController.canEdit']);
+
+ describe('#showSavePopup', function () {
+ var popup;
+ beforeEach(function () {
+ popup = getController().showSavePopup();
+ });
+
+ App.TestAliases.testAsComputedOr(getController().showSavePopup(), 'disablePrimary', ['App.router.mainAlertDefinitionDetailsController.editing.label.isError', 'App.router.mainAlertDefinitionConfigsController.hasErrors']);
+
+ });
+
describe('#labelValidation()', function () {
it('should set editing.label.isError to true', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index 6c48b64..25ed383 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -20,10 +20,16 @@ var App = require('app');
var controller;
var helpers = require('test/helpers');
+
+function getController() {
+ return App.ManageAlertNotificationsController.create({});
+}
+var createEditPopupView = getController().showCreateEditPopup();
+
describe('App.ManageAlertNotificationsController', function () {
beforeEach(function () {
- controller = App.ManageAlertNotificationsController.create({});
+ controller = getController();
sinon.stub($, 'ajax', Em.K);
});
@@ -503,13 +509,11 @@ describe('App.ManageAlertNotificationsController', function () {
});
- describe('#bodyClass', function () {
-
- var view;
-
- beforeEach(function () {
+ App.TestAliases.testAsComputedOr(getController().showCreateEditPopup(), 'disablePrimary', ['isSaving', 'hasErrors']);
- view = controller.showCreateEditPopup().get('bodyClass').create({
+ describe('#bodyClass', function () {
+ function getBodyClass() {
+ return createEditPopupView.get('bodyClass').create({
controller: Em.Object.create({
inputFields: {
name: {},
@@ -528,9 +532,16 @@ describe('App.ManageAlertNotificationsController', function () {
hasErrors: false
})
});
+ }
+
+ var view;
+ beforeEach(function () {
+ view = getBodyClass();
});
+ App.TestAliases.testAsComputedOr(getBodyClass(), 'someErrorExists', ['nameError', 'emailToError', 'emailFromError', 'smtpPortError', 'hostError', 'portError', 'passwordError']);
+
describe('#selectAllGroups', function () {
it('should check inputFields.allGroups.value', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 b42175b..bec3be1 100644
--- a/ambari-web/test/controllers/main/service/info/summary_test.js
+++ b/ambari-web/test/controllers/main/service/info/summary_test.js
@@ -19,6 +19,10 @@
var App = require('app');
require('controllers/main/service/info/summary');
+function getController() {
+ return App.MainServiceInfoSummaryController.create();
+}
+
describe('App.MainServiceInfoSummaryController', function () {
var controller;
@@ -27,6 +31,8 @@ describe('App.MainServiceInfoSummaryController', function () {
controller = App.MainServiceInfoSummaryController.create();
});
+App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isServiceWithEnhancedWidgets', 'someWidgetGraphExists']);
+
describe('#setRangerPlugins', function () {
var cases = [
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 b6f46f3..144918e 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
@@ -34,28 +34,7 @@ describe('App.WidgetWizardStep3Controller', function () {
App.TestAliases.testAsComputedGte(controller, 'isDescriptionInvalid', 'widgetDescription.length', 2049);
- describe("#isSubmitDisabled", function () {
- it("widgetName - null", function () {
- controller.set('widgetName', null);
- controller.propertyDidChange('isSubmitDisabled');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
- it("widgetName empty ", function () {
- controller.set('widgetName', '');
- controller.propertyDidChange('isSubmitDisabled');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
- it("widgetName contains only whitespace", function () {
- controller.set('widgetName', ' ');
- controller.propertyDidChange('isSubmitDisabled');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
- it("widgetName correct", function () {
- controller.set('widgetName', 'w1');
- controller.propertyDidChange('isSubmitDisabled');
- expect(controller.get('isSubmitDisabled')).to.be.false;
- });
- });
+ App.TestAliases.testAsComputedOr(controller, 'isSubmitDisabled', ['widgetNameEmpty', 'isNameInvalid', 'isDescriptionInvalid']);
describe("#initPreviewData()", function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 9afad41..41782bc 100644
--- a/ambari-web/test/controllers/wizard/step2_test.js
+++ b/ambari-web/test/controllers/wizard/step2_test.js
@@ -74,6 +74,8 @@ describe('App.WizardStep2Controller', function () {
App.TestAliases.testAsComputedAlias(getController(), 'agentUser', 'content.installOptions.agentUser', 'string');
+ App.TestAliases.testAsComputedOr(getController(), 'isSubmitDisabled', ['hostsError', 'sshKeyError', 'sshUserError', 'sshPortError', 'agentUserError']);
+
describe('#hostNames', function() {
it('should be equal to content.installOptions.hostNames', function() {
var controller = App.WizardStep2Controller.create({content: {installOptions: {hostNames: 'A,b,C'}}});
@@ -471,46 +473,6 @@ describe('App.WizardStep2Controller', function () {
});
- describe('#isSubmitDisabled', function () {
-
- var controller = App.WizardStep2Controller.create({
- hostsError: '',
- sshKeyError: '',
- sshUserError: '',
- sshPortError: '',
- agentUserError: ''
- });
-
- it('should return value if hostsError is not empty', function () {
- controller.set('hostsError', 'error');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
-
- it('should return value if sshKeyError is not empty', function () {
- controller.set('sshKeyError', 'error');
- controller.set('hostsError', '');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
-
- it('should return value if sshUserError is not empty', function () {
- controller.set('sshUserError', 'error');
- controller.set('sshKeyError', '');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
-
- it('should return value if agentUserError is not empty', function () {
- controller.set('agentUserError', 'error');
- controller.set('sshUserError', '');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
-
- it('should return value if sshPortError is not empty', function () {
- controller.set('sshPortError', 'error');
- controller.set('agentUserError', '');
- expect(controller.get('isSubmitDisabled')).to.be.true;
- });
- });
-
describe('#installedHostsPopup', function() {
beforeEach(function() {
sinon.spy(App.ModalPopup, 'show');
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 a699dcc..dd1e918 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -57,6 +57,8 @@ describe('App.WizardStep3Controller', function () {
App.TestAliases.testAsComputedIfThenElse(getController(), 'registrationTimeoutSecs', 'content.installOptions.manualInstall', 15, 120);
+ App.TestAliases.testAsComputedAnd(getController(), 'isWarningsLoaded', ['isJDKWarningsLoaded', 'isHostsWarningsLoaded']);
+
describe('#getAllRegisteredHostsCallback', function () {
it('One host is already in the cluster, one host is registered', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 056c30a..fdeaf0d 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -208,27 +208,7 @@ describe('App.WizardStep6Controller', function () {
});
});
- describe('#anyGeneralErrors', function () {
- beforeEach(function () {
- controller.set('errorMessage', undefined);
- });
- it('should return errorMessage', function () {
- controller.set('errorMessage', "error 404");
- expect(controller.get('anyGeneralErrors')).to.be.true
- });
- it('true if generalErrorMessages is non empty array and errorMessage is undefined', function () {
- controller.set('generalErrorMessages', ["error1", "error2"]);
- expect(controller.get('anyGeneralErrors')).to.equal(true);
- });
- it('false if generalErrorMessages is empty array and errorMessage is undefined', function () {
- controller.set('generalErrorMessages', []);
- expect(controller.get('anyGeneralErrors')).to.equal(false);
- });
- it('undefined if generalErrorMessages is undefined and errorMessage is undefined', function () {
- controller.set('generalErrorMessages', undefined);
- expect(controller.get('anyGeneralErrors')).to.equal(false);
- });
- });
+ App.TestAliases.testAsComputedOr(getController(), 'anyGeneralErrors', ['errorMessage', 'generalErrorMessages.length']);
describe('#render', function () {
it('true if loaded', function () {
@@ -309,31 +289,11 @@ describe('App.WizardStep6Controller', function () {
});
});
- describe('#anyGeneralIssues', function () {
- it('should return error message if errorMessage', function () {
- controller.set('errorMessage', "error 404");
- expect(controller.get('anyGeneralIssues')).to.be.true;
- });
- it('should return true if we have several errors', function () {
- controller.set('generalErrorMessages', ["error 404", "error"]);
- expect(controller.get('anyGeneralIssues')).to.be.true;
- });
- it('should return true if we have several warnings', function () {
- controller.set('generalWarningMessages', ["error 404", "error"]);
- expect(controller.get('anyGeneralIssues')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedOr(getController(), 'anyGeneralIssues', ['anyGeneralErrors', 'anyGeneralWarnings']);
- describe('#anyErrors', function () {
- it('true if generalErrorMessages is non empty', function () {
- controller.set('generalErrorMessages', ["error 404", "error"]);
- expect(controller.get('anyErrors')).to.equal(true);
- });
- it('false if generalErrorMessages is empty', function () {
- controller.set('generalErrorMessages', []);
- expect(controller.get('anyErrors')).to.equal(false);
- });
- });
+ App.TestAliases.testAsComputedOr(getController(), 'anyErrors', ['anyGeneralErrors', 'anyHostErrors']);
+
+ App.TestAliases.testAsComputedOr(getController(), 'anyWarnings', ['anyGeneralWarnings', 'anyHostWarnings']);
describe('#anyWarnings', function () {
it('true if generalWarningMessages is non empty', function () {
@@ -986,7 +946,7 @@ describe('App.WizardStep6Controller', function () {
});
});
-describe('#getCurrentBlueprint', function () {
+ describe('#getCurrentBlueprint', function () {
var tests = Em.A([
{
clientComponents: Em.A([{component_name: "name1"}]),
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 4d43a09..334563d 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -121,6 +121,8 @@ describe('App.InstallerStep7Controller', function () {
App.TestAliases.testAsComputedAlias(getController(), 'slaveComponentHosts', 'content.slaveGroupProperties', 'array');
+ App.TestAliases.testAsComputedAnd(getController(), 'isConfigsLoaded', ['wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded']);
+
describe('#installedServiceNames', function () {
var tests = Em.A([
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/init_computed_aliases.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/init_computed_aliases.js b/ambari-web/test/init_computed_aliases.js
index 030480d..62d0842 100644
--- a/ambari-web/test/init_computed_aliases.js
+++ b/ambari-web/test/init_computed_aliases.js
@@ -49,7 +49,6 @@ App.TestAliases = {
return this._stubOneKey.apply(this, args);
}
return this._stubManyKeys.apply(this, args)
-
},
/**
@@ -136,6 +135,32 @@ App.TestAliases = {
return Em.get(self, k);
});
return this;
+ },
+
+ /**
+ * Generates array of all possible boolean combinations
+ * Example:
+ * <code>
+ * var keys = ['a', 'b'];
+ * var result = getBinaryCombos(keys);
+ * console.log(result); // [{a: true, b: true}, {a: true, b: false}, {a: false, b: true}, {a: false, b: false}]
+ * </code>
+ *
+ * @param {string[]} dependentKeys
+ * @returns {Array}
+ */
+ getBinaryCombos: function (dependentKeys) {
+ var n = dependentKeys.length;
+ var result = [];
+ var allCombos = Math.pow(2, n);
+ for (var y = 0; y < allCombos; y++) {
+ var combo = {};
+ for (var x = 0; x < n; x++) {
+ combo[dependentKeys[x]] = !!((y >> x) & 1);
+ }
+ result.push(combo);
+ }
+ return result;
}
}
@@ -166,4 +191,6 @@ require('test/aliases/computed/everyBy');
require('test/aliases/computed/mapBy');
require('test/aliases/computed/filterBy');
require('test/aliases/computed/findBy');
-require('test/aliases/computed/sumBy');
\ No newline at end of file
+require('test/aliases/computed/sumBy');
+require('test/aliases/computed/and');
+require('test/aliases/computed/or');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/models/alerts/alert_definition_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/alerts/alert_definition_test.js b/ambari-web/test/models/alerts/alert_definition_test.js
index c32dde4..d151faf 100644
--- a/ambari-web/test/models/alerts/alert_definition_test.js
+++ b/ambari-web/test/models/alerts/alert_definition_test.js
@@ -22,14 +22,18 @@ require('models/alerts/alert_definition');
var model;
+function getModel() {
+ return App.AlertDefinition.createRecord();
+}
+
describe('App.AlertDefinition', function () {
beforeEach(function () {
-
- model = App.AlertDefinition.createRecord();
-
+ model = getModel();
});
+ App.TestAliases.testAsComputedAnd(getModel(), 'isHostAlertDefinition', ['isAmbariService', 'isAmbariAgentComponent']);
+
describe('#status', function () {
Em.A([
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 11ea4ab..e292109 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -333,6 +333,8 @@ describe('App.ServiceConfigProperty', function () {
App.TestAliases.testAsComputedFirstNotBlank(getProperty(), 'placeholder', ['placeholderText', 'savedValue']);
+ App.TestAliases.testAsComputedAnd(getProperty(), 'hideFinalIcon', ['!isFinal', 'isNotEditable']);
+
describe('#overrideErrorTrigger', function () {
it('should be an increment', function () {
serviceConfigProperty.set('overrides', configsData[0].overrides);
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/models/configs/service_config_version_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/service_config_version_test.js b/ambari-web/test/models/configs/service_config_version_test.js
index e721890..b5b730c 100644
--- a/ambari-web/test/models/configs/service_config_version_test.js
+++ b/ambari-web/test/models/configs/service_config_version_test.js
@@ -21,10 +21,14 @@ require('models/configs/service_config_version');
var model;
+function getModel() {
+ return App.ServiceConfigVersion.createRecord({});
+}
+
describe('App.ServiceConfigVersion', function () {
beforeEach(function () {
- model = App.ServiceConfigVersion.createRecord({});
+ model = getModel();
});
describe('#authorFormatted', function () {
@@ -51,39 +55,6 @@ describe('App.ServiceConfigVersion', function () {
});
- describe('#canBeMadeCurrent', function () {
-
- var cases = [
- {
- isCompatible: true,
- isCurrent: true,
- canBeMadeCurrent: false,
- title: 'current version'
- },
- {
- isCompatible: true,
- isCurrent: false,
- canBeMadeCurrent: true,
- title: 'compatible version'
- },
- {
- isCompatible: false,
- isCurrent: false,
- canBeMadeCurrent: false,
- title: 'not compatible version'
- }
- ];
-
- cases.forEach(function (item) {
- it(item.title, function () {
- model.setProperties({
- isCompatible: item.isCompatible,
- isCurrent: item.isCurrent
- });
- expect(model.get('canBeMadeCurrent')).to.equal(item.canBeMadeCurrent);
- });
- });
-
- });
+ App.TestAliases.testAsComputedAnd(getModel(), 'canBeMadeCurrent', ['isCompatible', '!isCurrent']);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/models/configs/sub_section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/sub_section_test.js b/ambari-web/test/models/configs/sub_section_test.js
index 1e1e356..afc37b2 100644
--- a/ambari-web/test/models/configs/sub_section_test.js
+++ b/ambari-web/test/models/configs/sub_section_test.js
@@ -19,12 +19,24 @@
var App = require('app');
var model;
+function getModel() {
+ return App.SubSection.createRecord();
+}
+
describe('App.SubSection', function () {
beforeEach(function () {
- model = App.SubSection.createRecord();
+ model = getModel();
});
+ App.TestAliases.testAsComputedAnd(getModel(), 'showTabs', ['hasTabs', 'someSubSectionTabIsVisible']);
+
+ App.TestAliases.testAsComputedAnd(getModel(), 'addLeftVerticalSplitter', ['!isFirstColumn', 'leftVerticalSplitter']);
+
+ App.TestAliases.testAsComputedAnd(getModel(), 'showTopSplitter', ['!isFirstRow', '!border']);
+
+ App.TestAliases.testAsComputedAnd(getModel(), 'isSectionVisible', ['!isHiddenByFilter', '!isHiddenByConfig', 'someConfigIsVisible']);
+
describe('#errorsCount', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/models/stack_service_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/stack_service_component_test.js b/ambari-web/test/models/stack_service_component_test.js
index cc58fcb..7e971ce 100644
--- a/ambari-web/test/models/stack_service_component_test.js
+++ b/ambari-web/test/models/stack_service_component_test.js
@@ -302,6 +302,8 @@ describe('App.StackServiceComponent', function() {
modelSetup.setupStackServiceComponent();
});
+ App.TestAliases.testAsComputedAnd(App.StackServiceComponent.createRecord(), 'isMasterAddableInstallerWizard', ['isMaster', 'isMultipleAllowed', '!isMasterAddableOnlyOnHA', '!isNotAddableOnlyInInstall']);
+
describe('component properties validation', function() {
componentPropertiesValidationTests.forEach(function(test) {
describe('properties validation for ' + test.componentName + ' component', function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
index d2523ac..e7f979b 100644
--- a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
@@ -19,20 +19,29 @@
var App = require('app');
var view;
+
+function getView() {
+ return App.ConfigWidgetView.create({
+ initPopover: Em.K,
+ config: Em.Object.create({
+ isOriginalSCP: false,
+ isPropertyOverridable: false,
+ cantBeUndone: false,
+ isNotDefaultValue: false
+ })
+ });
+}
+
describe('App.ConfigWidgetView', function () {
beforeEach(function () {
- view = App.ConfigWidgetView.create({
- initPopover: Em.K,
- config: Em.Object.create({
- isOriginalSCP: false,
- isPropertyOverridable: false,
- cantBeUndone: false,
- isNotDefaultValue: false
- })
- });
+ view = getView();
});
+ App.TestAliases.testAsComputedAnd(getView(), 'showPencil', ['supportSwitchToTextBox', '!disabled']);
+
+ App.TestAliases.testAsComputedOr(getView(), 'doNotShowWidget', ['isPropertyUndefined', 'config.showAsTextBox']);
+
describe('#undoAllowed', function () {
Em.A([
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/common/form/spinner_input_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/form/spinner_input_view_test.js b/ambari-web/test/views/common/form/spinner_input_view_test.js
index 075ca88..8e668a0 100644
--- a/ambari-web/test/views/common/form/spinner_input_view_test.js
+++ b/ambari-web/test/views/common/form/spinner_input_view_test.js
@@ -20,10 +20,15 @@ var App = require('app');
var view;
var e;
+
+function getView() {
+ return App.SpinnerInputView.create({});
+}
+
describe('App.SpinnerInputView', function () {
beforeEach(function () {
- view = App.SpinnerInputView.create({});
+ view = getView();
e = {
preventDefault: Em.K
};
@@ -34,6 +39,8 @@ describe('App.SpinnerInputView', function () {
e.preventDefault.restore();
});
+ App.TestAliases.testAsComputedOr(getView(), 'computedDisabled', ['!content.enabled', 'disabled']);
+
describe('#keyDown', function () {
Em.A([
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 de578a1..66e6d41 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
@@ -28,6 +28,8 @@ describe('App.upgradeTaskView', function () {
view.removeObserver('content.isExpanded', view, 'doPolling');
view.removeObserver('outsideView', view, 'doPolling');
+ App.TestAliases.testAsComputedOr(view, 'showContent', ['outsideView', 'content.isExpanded']);
+
describe("#logTabId", function() {
it("", function() {
view.reopen({
@@ -158,31 +160,4 @@ describe('App.upgradeTaskView', function () {
});
});
- describe("#showContent", function() {
- it("outsideView = false, content.isExpanded = false", function() {
- view.set('outsideView', false);
- view.set('content.isExpanded', false);
- view.propertyDidChange('showContent');
- expect(view.get('showContent')).to.be.false;
- });
- it("outsideView = true, content.isExpanded = false", function() {
- view.set('outsideView', true);
- view.set('content.isExpanded', false);
- view.propertyDidChange('showContent');
- expect(view.get('showContent')).to.be.true;
- });
- it("outsideView = false, content.isExpanded = true", function() {
- view.set('outsideView', false);
- view.set('content.isExpanded', true);
- view.propertyDidChange('showContent');
- expect(view.get('showContent')).to.be.true;
- });
- it("outsideView = true, content.isExpanded = true", function() {
- view.set('outsideView', true);
- view.set('content.isExpanded', true);
- view.propertyDidChange('showContent');
- expect(view.get('showContent')).to.be.true;
- });
- });
-
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/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 a9fdfed..9507e08 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,8 @@ describe('App.upgradeWizardView', function () {
});
view.removeObserver('App.clusterName', view, 'startPolling');
+ App.TestAliases.testAsComputedOr(view, 'isManualProceedDisabled', ['!isManualDone', 'controller.requestInProgress']);
+
App.TestAliases.testAsComputedEqualProperties(view, 'isFinalizeItem', 'manualItem.context', 'controller.finalizeContext');
describe("#upgradeGroups", function () {
@@ -231,21 +233,6 @@ describe('App.upgradeWizardView', function () {
});
});
- describe("#isManualProceedDisabled", function () {
- it("requestInProgress is false", function () {
- view.set('isManualDone', true);
- view.set('controller.requestInProgress', false);
- view.propertyDidChange('isManualProceedDisabled');
- expect(view.get('isManualProceedDisabled')).to.be.false;
- });
- it("requestInProgress is true", function () {
- view.set('controller.requestInProgress', true);
- view.propertyDidChange('isManualProceedDisabled');
- expect(view.get('isManualProceedDisabled')).to.be.true;
- });
-
- });
-
describe("#failedItem", function () {
it("no running item", function () {
view.set('activeGroup.upgradeItems', []);
@@ -390,20 +377,7 @@ describe('App.upgradeWizardView', function () {
});
});
- describe("#isDowngradeAvailable", function () {
- it("downgrade available", function () {
- view.set('controller.isDowngrade', false);
- view.set('controller.downgradeAllowed', true);
- view.propertyDidChange('isDowngradeAvailable');
- expect(view.get('isDowngradeAvailable')).to.be.true;
- });
- it("downgrade unavailable", function () {
- view.set('controller.isDowngrade', true);
- view.set('controller.downgradeAllowed', true);
- view.propertyDidChange('isDowngradeAvailable');
- expect(view.get('isDowngradeAvailable')).to.be.false;
- });
- });
+ App.TestAliases.testAsComputedAnd(view, 'isDowngradeAvailable', ['!controller.isDowngrade', 'controller.downgradeAllowed']);
describe("#taskDetails", function () {
it("runningItem present", function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/main/alerts/definition_details_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alerts/definition_details_view_test.js b/ambari-web/test/views/main/alerts/definition_details_view_test.js
index ae4ac99..f988ceb 100644
--- a/ambari-web/test/views/main/alerts/definition_details_view_test.js
+++ b/ambari-web/test/views/main/alerts/definition_details_view_test.js
@@ -20,16 +20,17 @@ var App = require('app');
var view, instanceTableRow;
+function getView() {
+ return App.MainAlertDefinitionDetailsView.create({
+ initFilters: Em.K
+ });
+}
+
describe('App.MainAlertDefinitionDetailsView', function () {
beforeEach(function () {
-
- view = App.MainAlertDefinitionDetailsView.create({
- initFilters: Em.K
- });
-
+ view = getView();
instanceTableRow = view.get('instanceTableRow').create();
-
});
describe("#goToHostAlerts()", function () {
@@ -54,3 +55,13 @@ describe('App.MainAlertDefinitionDetailsView', function () {
});
});
+
+function getInstanceView() {
+ return App.AlertInstanceServiceHostView.create();
+}
+
+describe('App.AlertInstanceServiceHostView', function () {
+
+ App.TestAliases.testAsComputedAnd(getInstanceView(), 'showSeparator', ['instance.serviceDisplayName', 'instance.hostName']);
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
index 3615ccc..ce39742 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
@@ -109,4 +109,6 @@ describe('App.HBaseRegionsInTransitionView', function() {
App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1');
+ App.TestAliases.testAsComputedAnd(getView(), 'isOrange', ['!isGreen', '!isRed']);
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/main/dashboard/widgets/node_managers_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/node_managers_live_test.js b/ambari-web/test/views/main/dashboard/widgets/node_managers_live_test.js
index cd1c150..3e5fce0 100644
--- a/ambari-web/test/views/main/dashboard/widgets/node_managers_live_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/node_managers_live_test.js
@@ -23,84 +23,16 @@ require('views/main/dashboard/widget');
require('views/main/dashboard/widgets/text_widget');
require('views/main/dashboard/widgets/node_managers_live');
-describe('App.NodeManagersLiveView', function() {
-
- beforeEach(function () {
- sinon.stub(App, 'get').withArgs('router.clusterController.isComponentsStateLoaded').returns(true);
+function getView() {
+ return App.NodeManagersLiveView.create({
+ parentView: Em.Object.create()
});
+}
- afterEach(function () {
- App.get.restore();
- });
+describe('App.NodeManagersLiveView', function() {
- var tests = [
- {
- model: {
- nodeManagersTotal: 3,
- nodeManagerLiveNodes: 2
- },
- e: {
- isRed: false,
- isOrange: true,
- isGreen: false,
- isNA: false,
- content: '2/3',
- data: 67
- }
- },
- {
- model: {
- nodeManagersTotal: 2,
- nodeManagerLiveNodes: 2
- },
- e: {
- isRed: false,
- isOrange: false,
- isGreen: true,
- isNA: false,
- content: '2/2',
- data: 100
- }
- },
- {
- model: {
- nodeManagersTotal: 2,
- nodeManagerLiveNodes: 0
- },
- e: {
- isRed: true,
- isOrange: false,
- isGreen: false,
- isNA: false,
- content: '0/2',
- data: 0.00
- }
- }
- ];
+ App.TestAliases.testAsComputedAnd(getView(), 'isDataAvailable', ['!model.metricsNotAvailable', 'App.router.clusterController.isComponentsStateLoaded']);
- tests.forEach(function(test) {
- describe('nodeManagersTotal length - ' + test.model.nodeManagersTotal + ' | nodeManagerLiveNodes length - ' + test.model.nodeManagerLiveNodes, function() {
- var AppNodeManagersLiveView = App.NodeManagersLiveView.extend({nodeManagersLive: test.model.nodeManagerLiveNodes});
- var nodeManagersLiveView = AppNodeManagersLiveView.create({model_type:null, model: test.model});
- it('content', function() {
- expect(nodeManagersLiveView.get('content')).to.equal(test.e.content);
- });
- it('data', function() {
- expect(nodeManagersLiveView.get('data')).to.equal(test.e.data);
- });
- it('isRed', function() {
- expect(nodeManagersLiveView.get('isRed')).to.equal(test.e.isRed);
- });
- it('isOrange', function() {
- expect(nodeManagersLiveView.get('isOrange')).to.equal(test.e.isOrange);
- });
- it('isGreen', function() {
- expect(nodeManagersLiveView.get('isGreen')).to.equal(test.e.isGreen);
- });
- it('isNA', function() {
- expect(nodeManagersLiveView.get('isNA')).to.equal(test.e.isNA);
- });
- });
- });
+ App.TestAliases.testAsComputedAlias(getView(), 'nodeManagersLive', 'model.nodeManagersCountActive');
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
index 1f95076..5dbb599 100644
--- a/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/text_widget_test.js
@@ -89,4 +89,6 @@ describe('App.TextDashboardWidgetView', function() {
App.TestAliases.testAsComputedLteProperties(getView(), 'isRed', 'data', 'thresh1');
+ App.TestAliases.testAsComputedAnd(getView(), 'isOrange', ['!isGreen', '!isRed']);
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8750537a/ambari-web/test/views/wizard/step1_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step1_view_test.js b/ambari-web/test/views/wizard/step1_view_test.js
index a470495..497da5e 100644
--- a/ambari-web/test/views/wizard/step1_view_test.js
+++ b/ambari-web/test/views/wizard/step1_view_test.js
@@ -28,6 +28,8 @@ function getView() {
describe('App.WizardStep1View', function () {
+ App.TestAliases.testAsComputedAnd(getView(), 'showErrorsWarningCount', ['isSubmitDisabled', 'totalErrorCnt']);
+
describe('#operatingSystems', function () {
beforeEach(function () {
sinon.stub(App.Stack, 'find', function () {
@@ -210,6 +212,8 @@ describe('App.WizardStep1View', function () {
App.TestAliases.testAsComputedEveryBy(getView(), 'isNoOsChecked', 'operatingSystems', 'isSelected', false);
+ App.TestAliases.testAsComputedOr(getView(), 'isSubmitDisabled', ['invalidFormatUrlExist', 'isNoOsChecked', 'invalidUrlExist', 'controller.content.isCheckInProgress']);
+
describe('#stacks', function () {
var tests = Em.A([
@@ -245,148 +249,9 @@ describe('App.WizardStep1View', function () {
});
- describe('#isSubmitDisabled', function () {
-
- var tests = Em.A([
- {
- invalidFormatUrlExist: false,
- isNoOsChecked: false,
- invalidUrlExist: false,
- checkInProgress: false,
- e: false
- },
- {
- invalidFormatUrlExist: true,
- isNoOsChecked: false,
- invalidUrlExist: false,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: false,
- isNoOsChecked: true,
- invalidUrlExist: false,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: false,
- isNoOsChecked: false,
- invalidUrlExist: true,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: true,
- isNoOsChecked: false,
- invalidUrlExist: true,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: true,
- isNoOsChecked: true,
- invalidUrlExist: false,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: false,
- isNoOsChecked: true,
- invalidUrlExist: true,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: true,
- isNoOsChecked: true,
- invalidUrlExist: true,
- checkInProgress: false,
- e: true
- },
- {
- invalidFormatUrlExist: true,
- isNoOsChecked: false,
- invalidUrlExist: false,
- checkInProgress: true,
- e: true
- }
- ]);
+ App.TestAliases.testAsComputedSomeBy(getView(), 'invalidUrlExist', 'allRepositories', 'validation', App.Repository.validation['INVALID']);
- tests.forEach(function (test) {
- it(test.invalidFormatUrlExist.toString() + ' ' + test.isNoOsChecked.toString() + ' ' + test.invalidUrlExist.toString()+ ' ' + test.checkInProgress.toString(), function () {
- view = App.WizardStep1View.create();
- view.reopen({
- invalidFormatUrlExist: test.invalidFormatUrlExist,
- isNoOsChecked: test.isNoOsChecked,
- invalidUrlExist: test.invalidUrlExist
- });
- view.set('controller', {});
- view.set('controller.content', {});
- view.set('controller.content.isCheckInProgress', test.checkInProgress);
- expect(view.get('isSubmitDisabled')).to.equal(test.e);
- });
- });
- });
-
- describe('#showErrorsWarningCount', function() {
- var tests = [
- {
- isSubmitDisabled: true,
- totalErrorCnt: 0,
- e: false
- },
- {
- isSubmitDisabled: true,
- totalErrorCnt: 1,
- e: true
- },
- {
- isSubmitDisabled: false,
- totalErrorCnt: 0,
- e: false
- }
- ];
- tests.forEach(function(test) {
- it(test.isSubmitDisabled.toString() + ' ' + test.totalErrorCnt.toString(), function () {
- var view = App.WizardStep1View.create();
- view.reopen({
- isSubmitDisabled: test.isSubmitDisabled,
- totalErrorCnt: test.totalErrorCnt
- });
- expect(view.get('showErrorsWarningCount')).to.equal(test.e);
- })
- });
- });
-
- describe('#invalidUrlExist', function () {
- var tests = Em.A([
- {
- allRepositories: [Em.Object.create({validation: 'icon-exclamation-sign'})],
- m: 'invalidCnt: 1, validation: icon-exclamation-sign',
- e: true
- },
- {
- allRepositories: [Em.Object.create({validation: ''})],
- m: 'invalidCnt: 1, validation: ""',
- e: false
- },
- {
- allRepositories: [Em.Object.create({validation: ''})],
- m: 'invalidCnt: 0, validation: ""',
- e: false
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- view = App.WizardStep1View.create();
- view.reopen({
- allRepositories: test.allRepositories
- });
- expect(view.get('invalidUrlExist')).to.equal(test.e);
- });
- });
- });
+ App.TestAliases.testAsComputedSomeBy(getView(), 'invalidFormatUrlExist', 'allRepositories', 'invalidFormatError', true);
describe('#totalErrorCnt', function () {
var tests = Em.A([
[2/5] ambari git commit: AMBARI-14297. Apply common tests for
Em.computed macros (onechiporenko)
Posted by on...@apache.org.
AMBARI-14297. Apply common tests for Em.computed macros (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/43306594
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/43306594
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/43306594
Branch: refs/heads/trunk
Commit: 43306594eae138b6b8e2bf6acfe1866c20cf67ae
Parents: 240a27a
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Dec 9 17:50:51 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Dec 10 15:45:37 2015 +0200
----------------------------------------------------------------------
.../global/cluster_controller_test.js | 2 +
.../global/update_controller_test.js | 2 +
.../admin/kerberos/step2_controller_test.js | 13 +-
.../admin/kerberos/step4_controller_test.js | 10 +-
.../controllers/main/admin/kerberos_test.js | 4 +
.../definitions_details_controller_test.js | 16 +-
.../manage_alert_groups_controller_test.js | 9 +-
.../controllers/main/charts/heatmap_test.js | 8 +
.../test/controllers/main/host/details_test.js | 25 ++-
.../main/host/host_alerts_controller_test.js | 9 +-
.../main/service/info/config_test.js | 25 ++-
.../test/controllers/main/service/item_test.js | 2 -
.../widgets/create/step2_controller_test.js | 13 +-
.../widgets/create/step3_controller_test.js | 30 +--
.../test/controllers/main/service_test.js | 47 +----
ambari-web/test/controllers/main_test.js | 24 +--
.../test/controllers/wizard/step10_test.js | 11 +-
.../test/controllers/wizard/step2_test.js | 82 ++------
.../test/controllers/wizard/step3_test.js | 63 ++----
.../test/controllers/wizard/step6_test.js | 76 +++----
.../test/controllers/wizard/step7_test.js | 46 ++---
.../test/controllers/wizard/step8_test.js | 96 +++++----
.../test/controllers/wizard/step9_test.js | 50 +++--
ambari-web/test/models/authentication_test.js | 4 +
ambari-web/test/models/cluster_states_test.js | 13 +-
.../objects/service_config_category_test.js | 22 +--
.../objects/service_config_property_test.js | 8 +-
ambari-web/test/models/configs/section_test.js | 56 +-----
ambari-web/test/models/host_component_test.js | 63 +-----
ambari-web/test/models/host_test.js | 10 +
ambari-web/test/models/repository_test.js | 12 +-
ambari-web/test/models/stack_service_test.js | 13 +-
ambari-web/test/models/upgrade_entity_test.js | 8 +-
ambari-web/test/models/user_test.js | 30 ++-
.../common/configs/config_history_flow_test.js | 14 ++
.../notification_configs_view_test.js | 32 +--
.../service_configs_by_category_view_test.js | 3 +
.../form/manage_kdc_credentials_form_test.js | 16 +-
ambari-web/test/views/common/table_view_test.js | 8 +
.../nameNode/step4_view_test.js | 14 +-
.../stack_upgrade/upgrade_wizard_view_test.js | 14 +-
.../views/main/alert_definitions_view_test.js | 8 +-
.../alerts/manage_alert_groups_view_test.js | 14 +-
.../widgets/hbase_average_load_test.js | 10 +
.../widgets/hbase_regions_in_transition_test.js | 10 +
.../main/dashboard/widgets/namenode_rpc_test.js | 8 +
.../main/dashboard/widgets/text_widget_test.js | 8 +
.../host/details/host_component_view_test.js | 197 +++----------------
ambari-web/test/views/main/host_test.js | 12 +-
.../views/main/service/info/summary_test.js | 9 +
ambari-web/test/views/main/service/item_test.js | 15 ++
ambari-web/test/views/wizard/step1_view_test.js | 41 +---
ambari-web/test/views/wizard/step2_view_test.js | 15 +-
.../wizard/step3/hostLogPopupBody_view_test.js | 24 +--
.../step3/hostWarningPopupBody_view_test.js | 24 ++-
ambari-web/test/views/wizard/step6_view_test.js | 21 +-
.../wizard/step9/hostLogPopupBody_view_test.js | 25 ++-
57 files changed, 569 insertions(+), 875 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index 1cc5267..2b01ea0 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -35,6 +35,8 @@ describe('App.clusterController', function () {
{service_name: 'GANGLIA'}
];
+ App.TestAliases.testAsComputedAlias(controller, 'clusterName', 'App.clusterName', 'string');
+
describe('#updateLoadStatus()', function () {
controller.set('dataLoadList', Em.Object.create({
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 8e68b21..fc29aa0 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -28,6 +28,8 @@ describe('App.UpdateController', function () {
updateServiceMetric: function(){}
});
+ App.TestAliases.testAsComputedAlias(App.UpdateController.create(), 'clusterName', 'App.router.clusterController.clusterName', 'string');
+
describe('#getUrl()', function () {
it('testMode = true', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js
index 9a06024..c87c86c 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js
@@ -19,14 +19,24 @@
var App = require('app');
var setups = require('test/init_model_test');
+function getController() {
+ return App.KerberosWizardStep2Controller.create({});
+}
+
describe('App.KerberosWizardStep2Controller', function() {
+ App.TestAliases.testAsComputedAlias(getController(), 'isBackBtnDisabled', 'testConnectionInProgress', 'boolean');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'hostNames', 'App.allHostNames');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'isConfigsLoaded', 'wizardController.stackConfigsLoaded', 'boolean');
+
describe('#createKerberosSiteObj', function() {
var controller;
beforeEach(function() {
setups.setupStackVersion(this, 'HDP-2.3');
- controller = App.KerberosWizardStep2Controller.create({});
+ controller = getController();
sinon.stub(controller, 'tweakKdcTypeValue', Em.K);
sinon.stub(controller, 'tweakManualKdcProperties', Em.K);
});
@@ -84,4 +94,5 @@ describe('App.KerberosWizardStep2Controller', function() {
});
});
});
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 18858cf..7b2f877 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -17,9 +17,15 @@
*/
var App = require('app');
-
+var c = App.KerberosWizardStep4Controller.create({
+ wizardController: Em.Object.create({
+ name: ''
+ })
+});
describe('App.KerberosWizardStep4Controller', function() {
-
+
+ App.TestAliases.testAsComputedEqual(c, 'isWithinAddService', 'wizardController.name', 'addServiceController');
+
describe('#isSubmitDisabled', function() {
var controller = App.KerberosWizardStep4Controller.create({});
var configs = Em.A([
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 6eb2bab..8130941 100644
--- a/ambari-web/test/controllers/main/admin/kerberos_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos_test.js
@@ -22,6 +22,10 @@ describe('App.MainAdminKerberosController', function() {
var controller = App.MainAdminKerberosController.create({});
+ App.TestAliases.testAsComputedEqual(controller, 'isManualKerberos', 'kdc_type', 'none');
+
+ App.TestAliases.testAsComputedSomeBy(controller, 'isPropertiesChanged', 'stepConfigs', 'isPropertiesChanged', true);
+
describe('#prepareConfigProperties', function() {
beforeEach(function() {
sinon.stub(App.Service, 'find').returns([
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
index dea1f2a..7b56068 100644
--- a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js
@@ -20,16 +20,22 @@ var App = require('app');
var controller;
+function getController() {
+ return App.MainAlertDefinitionDetailsController.create({
+ content: Em.Object.create({
+ label: 'label'
+ })
+ });
+}
+
describe('App.MainAlertDefinitionDetailsController', function () {
beforeEach(function () {
- controller = App.MainAlertDefinitionDetailsController.create({
- content: Em.Object.create({
- label: 'label'
- })
- });
+ controller = getController();
});
+ App.TestAliases.testAsComputedMapBy(getController(), 'groupsList', 'content.groups', 'displayName');
+
describe('#labelValidation()', function () {
it('should set editing.label.isError to true', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js
index dc1fc1f..db0f50a 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js
@@ -19,12 +19,19 @@
var App = require('app');
var manageAlertGroupsController;
+
+function getController() {
+ return App.ManageAlertGroupsController.create({});
+}
+
describe('App.ManageAlertGroupsController', function () {
beforeEach(function () {
- manageAlertGroupsController = App.ManageAlertGroupsController.create({});
+ manageAlertGroupsController = getController();
});
+ App.TestAliases.testAsComputedFilterBy(getController(), 'alertGlobalNotifications', 'alertNotifications', 'global', true);
+
describe('#addAlertGroup', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/charts/heatmap_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_test.js b/ambari-web/test/controllers/main/charts/heatmap_test.js
index 56c672c..dbdf8c3 100644
--- a/ambari-web/test/controllers/main/charts/heatmap_test.js
+++ b/ambari-web/test/controllers/main/charts/heatmap_test.js
@@ -21,8 +21,16 @@ var App = require('app');
require('models/rack');
require('controllers/main/charts/heatmap');
+function getController() {
+ return App.MainChartsHeatmapController.create();
+}
+
describe('MainChartsHeatmapController', function () {
+ App.TestAliases.testAsComputedAlias(getController(), 'activeWidget', 'widgets.firstObject', 'object');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'hostToSlotMap', 'selectedMetric.hostToSlotMap', 'object');
+
describe('#validation()', function () {
var controller = App.MainChartsHeatmapController.create({
allMetrics: [],
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 4608516..1ed9d47 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -26,24 +26,30 @@ var batchUtils = require('utils/batch_scheduled_requests');
var hostsManagement = require('utils/hosts');
var controller;
-describe('App.MainHostDetailsController', function () {
+function getController() {
+ return App.MainHostDetailsController.create(App.InstallComponent, {
+ content: Em.Object.create({
+ hostComponents: []
+ })
+ });
+}
+describe('App.MainHostDetailsController', function () {
beforeEach(function () {
sinon.stub(App.ajax, 'send').returns({
then: Em.K,
complete: Em.K
});
- controller = App.MainHostDetailsController.create(App.InstallComponent, {
- content: Em.Object.create({
- hostComponents: []
- })
- });
+ controller = getController();
});
+
afterEach(function () {
App.ajax.send.restore();
});
+ App.TestAliases.testAsComputedFilterBy(getController(), 'serviceNonClientActiveComponents', 'serviceActiveComponents', 'isClient', false);
+
describe('#routeHome()', function () {
it('transiotion to dashboard', function () {
sinon.stub(App.router, 'transitionTo', Em.K);
@@ -74,7 +80,7 @@ describe('App.MainHostDetailsController', function () {
});
});
-describe('#stopComponent()', function () {
+ describe('#stopComponent()', function () {
beforeEach(function () {
sinon.stub(App, 'showConfirmationPopup', function (callback) {
@@ -295,7 +301,6 @@ describe('#stopComponent()', function () {
});
});
-
describe('#serviceActiveComponents', function () {
it('No host-components', function () {
@@ -2105,7 +2110,6 @@ describe('#stopComponent()', function () {
});
});
-
describe('#setRackId', function () {
beforeEach(function () {
sinon.stub(hostsManagement, 'setRackInfo', Em.K);
@@ -2312,6 +2316,7 @@ describe('#stopComponent()', function () {
}))).to.equal(0);
});
});
+
describe('#downloadClientConfigsCall', function () {
beforeEach(function () {
@@ -2929,7 +2934,6 @@ describe('#stopComponent()', function () {
});
});
-
describe("#installVersion()", function () {
it("call App.ajax.send", function () {
controller.set('content.hostName', 'host1');
@@ -3398,4 +3402,5 @@ describe('#stopComponent()', function () {
expect(controller.checkComponentDependencies('C1', opt)).to.eql(['C3']);
});
});
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 ac75090..2cfdac5 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
@@ -22,12 +22,18 @@ require('controllers/main/host/host_alerts_controller');
var controller;
+function getController() {
+ return App.MainHostAlertsController.create();
+}
+
describe('App.MainHostAlertsController', function () {
beforeEach(function() {
- controller = App.MainHostAlertsController.create();
+ controller = getController();
});
+ App.TestAliases.testAsComputedAlias(getController(), 'selectedHost', 'App.router.mainHostDetailsController.content', 'object');
+
describe("#routeToAlertDefinition()", function () {
beforeEach(function () {
@@ -45,4 +51,5 @@ describe('App.MainHostAlertsController', function () {
expect(App.router.transitionTo.calledWith('main.alerts.alertDetails', 'alertDefinition')).to.be.true;
});
});
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index b324b12..aec369f 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -20,21 +20,28 @@ var App = require('app');
require('controllers/main/service/info/configs');
var batchUtils = require('utils/batch_scheduled_requests');
var mainServiceInfoConfigsController = null;
+
+function getController() {
+ return App.MainServiceInfoConfigsController.create({
+ dependentServiceNames: [],
+ loadDependentConfigs: function () {
+ return {done: Em.K}
+ },
+ loadConfigTheme: function () {
+ return $.Deferred().resolve().promise();
+ }
+ });
+}
+
describe("App.MainServiceInfoConfigsController", function () {
beforeEach(function () {
sinon.stub(App.themesMapper, 'generateAdvancedTabs').returns(Em.K);
- mainServiceInfoConfigsController = App.MainServiceInfoConfigsController.create({
- dependentServiceNames: [],
- loadDependentConfigs: function () {
- return {done: Em.K}
- },
- loadConfigTheme: function () {
- return $.Deferred().resolve().promise();
- }
- });
+ mainServiceInfoConfigsController = getController();
});
+ App.TestAliases.testAsComputedAlias(getController(), 'serviceConfigs', 'App.config.preDefinedServiceConfigs', 'array');
+
afterEach(function() {
App.themesMapper.generateAdvancedTabs.restore();
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 b3151dd..4934d21 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -318,7 +318,6 @@ describe('App.MainServiceItemController', function () {
});
});
-
describe("#turnOnOffPassive", function () {
var mainServiceItemController = App.MainServiceItemController.create({turnOnOffPassiveRequest: Em.K});
beforeEach(function () {
@@ -1058,7 +1057,6 @@ describe('App.MainServiceItemController', function () {
});
});
-
describe('#downloadClientConfigs()', function () {
var mainServiceItemController = App.MainServiceItemController.create({
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 fc9f66d..9d3efde 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
@@ -26,18 +26,7 @@ describe('App.WidgetWizardStep2Controller', function () {
content: Em.Object.create()
});
- describe("#isEditWidget", function () {
- it("empty name", function () {
- controller.set('content.controllerName', '');
- controller.propertyDidChange('isEditWidget');
- expect(controller.get('isEditWidget')).to.be.false;
- });
- it("correct name", function () {
- controller.set('content.controllerName', 'widgetEditController');
- controller.propertyDidChange('isEditWidget');
- expect(controller.get('isEditWidget')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedEqual(controller, 'isEditWidget', 'content.controllerName', 'widgetEditController');
describe("#filteredMetrics", function () {
var testCases = [
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 c603b48..b6f46f3 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
@@ -26,31 +26,13 @@ describe('App.WidgetWizardStep3Controller', function () {
content: Em.Object.create()
});
- describe("#isEditController", function () {
- it("empty name", function () {
- controller.set('content.controllerName', '');
- controller.propertyDidChange('isEditController');
- expect(controller.get('isEditController')).to.be.false;
- });
- it("widgetEditController name", function () {
- controller.set('content.controllerName', 'widgetEditController');
- controller.propertyDidChange('isEditController');
- expect(controller.get('isEditController')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedEqual(controller, 'isEditController', 'content.controllerName', 'widgetEditController');
- describe("#widgetScope", function () {
- it("isSharedChecked - false", function () {
- controller.set('isSharedChecked', false);
- controller.propertyDidChange('widgetScope');
- expect(controller.get('widgetScope')).to.equal('User');
- });
- it("isSharedChecked - true", function () {
- controller.set('isSharedChecked', true);
- controller.propertyDidChange('widgetScope');
- expect(controller.get('widgetScope')).to.equal('Cluster');
- });
- });
+ App.TestAliases.testAsComputedIfThenElse(controller, 'widgetScope', 'isSharedChecked', 'Cluster', 'User');
+
+ App.TestAliases.testAsComputedGte(controller, 'isNameInvalid', 'widgetName.length', 129);
+
+ App.TestAliases.testAsComputedGte(controller, 'isDescriptionInvalid', 'widgetDescription.length', 2049);
describe("#isSubmitDisabled", function () {
it("widgetName - null", function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js
index cad39f9..c134419 100644
--- a/ambari-web/test/controllers/main/service_test.js
+++ b/ambari-web/test/controllers/main/service_test.js
@@ -21,6 +21,10 @@ require('controllers/main/service');
var mainServiceController;
+function getController() {
+ return App.MainServiceController.create({});
+}
+
describe('App.MainServiceController', function () {
var tests = Em.A([
@@ -74,11 +78,12 @@ describe('App.MainServiceController', function () {
}
]);
-
beforeEach(function() {
- mainServiceController = App.MainServiceController.create();
+ mainServiceController = getController();
});
+ App.TestAliases.testAsComputedNotEqual(getController(), 'isStartStopAllClicked', 'App.router.backgroundOperationsController.allOperationsCount', 0);
+
describe('#isStartAllDisabled', function () {
tests.forEach(function (test) {
it(test.mStart, function () {
@@ -103,22 +108,6 @@ describe('App.MainServiceController', function () {
});
});
- describe('#isStartStopAllClicked', function () {
-
- beforeEach(function () {
- sinon.stub(App, 'get').withArgs('router.backgroundOperationsController.allOperationsCount').returns(1);
- });
-
- afterEach(function () {
- App.get.restore();
- });
-
- it('should be based on BG ops count', function () {
- expect(mainServiceController.get('isStartStopAllClicked')).to.be.true;
- });
-
- });
-
describe('#cluster', function() {
var tests = Em.A([
@@ -326,27 +315,7 @@ describe('App.MainServiceController', function () {
});
- describe('#isRestartAllRequiredDisabled', function () {
-
- it('should be false if there is at least one service with isRestartRequired=true', function () {
- mainServiceController.reopen({
- content: [
- {isRestartRequired: false}, {isRestartRequired: false}, {isRestartRequired: true}
- ]
- });
- expect(mainServiceController.get('isRestartAllRequiredDisabled')).to.be.false;
- });
-
- it('should be true if there is no services with isRestartRequired=true', function () {
- mainServiceController.reopen({
- content: [
- {isRestartRequired: false}, {isRestartRequired: false}, {isRestartRequired: false}
- ]
- });
- expect(mainServiceController.get('isRestartAllRequiredDisabled')).to.be.true;
- });
-
- });
+ App.TestAliases.testAsComputedEveryBy(getController(), 'isRestartAllRequiredDisabled', 'content', 'isRestartRequired', false);
describe('#restartAllRequired', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main_test.js b/ambari-web/test/controllers/main_test.js
index 867fc4b..f9f092a 100644
--- a/ambari-web/test/controllers/main_test.js
+++ b/ambari-web/test/controllers/main_test.js
@@ -56,29 +56,9 @@ describe('App.MainController', function () {
});
});
- describe('#isClusterDataLoaded', function() {
- beforeEach(function () {
- sinon.stub(App.router, 'get').returns(true);
- });
- afterEach(function () {
- App.router.get.restore();
- });
- it ('Should return true', function() {
- expect(mainController.get('isClusterDataLoaded')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedAlias(mainController, 'isClusterDataLoaded', 'App.router.clusterController.isLoaded', 'boolean');
- describe('#clusterDataLoadedPercent', function() {
- beforeEach(function () {
- sinon.stub(App, 'get').withArgs('router.clusterController.clusterDataLoadedPercent').returns(16);
- });
- afterEach(function () {
- App.get.restore();
- });
- it ('Should return 16', function() {
- expect(mainController.get('clusterDataLoadedPercent')).to.be.equal(16);
- });
- });
+ App.TestAliases.testAsComputedAlias(mainController, 'clusterDataLoadedPercent', 'App.router.clusterController.clusterDataLoadedPercent', 'string');
describe('#initialize', function() {
var initialize = false;
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step10_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step10_test.js b/ambari-web/test/controllers/wizard/step10_test.js
index 0c2bbef..8238e89 100644
--- a/ambari-web/test/controllers/wizard/step10_test.js
+++ b/ambari-web/test/controllers/wizard/step10_test.js
@@ -23,17 +23,24 @@ require('controllers/wizard/step10_controller');
var controller;
+function getController() {
+ return App.WizardStep10Controller.create({
+ content: {cluster: {controllerName: '', status: 'INSTALL COMPLETE'}}
+ });
+}
+
describe('App.WizardStep10Controller', function () {
beforeEach(function() {
- controller = App.WizardStep10Controller.create();
- controller.set('content', {cluster: {status: 'INSTALL COMPLETE'}});
+ controller = getController();
});
afterEach(function() {
controller.clearStep();
});
+ App.TestAliases.testAsComputedEqual(getController(), 'isAddServiceWizard', 'content.controllerName', 'addServiceController');
+
describe('#clearStep', function() {
it('should clear clusterInfo', function() {
controller.get('clusterInfo').pushObject({});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 b137669..9afad41 100644
--- a/ambari-web/test/controllers/wizard/step2_test.js
+++ b/ambari-web/test/controllers/wizard/step2_test.js
@@ -23,6 +23,11 @@ require('models/host');
require('models/host_component');
require('messages');
var c;
+
+function getController() {
+ return App.WizardStep2Controller.create({content: {controllerName: ''}});
+}
+
describe('App.WizardStep2Controller', function () {
var userErrorTests = Em.A([
@@ -54,28 +59,20 @@ describe('App.WizardStep2Controller', function () {
beforeEach(function() {
- c = App.WizardStep2Controller.create();
+ c = getController();
});
- describe('#isInstaller', function() {
- it('true if controllerName is installerController', function() {
- var controller = App.WizardStep2Controller.create({content: {controllerName: 'installerController'}});
- expect(controller.get('isInstaller')).to.equal(true);
- });
- it('false if controllerName isn\'t installerController', function() {
- var controller = App.WizardStep2Controller.create({content: {controllerName: 'addServiceController'}});
- expect(controller.get('isInstaller')).to.equal(false);
- });
- });
+ App.TestAliases.testAsComputedEqual(getController(), 'isInstaller', 'content.controllerName', 'installerController');
- describe('#manualInstall', function() {
- it('should be equal to content.installOptions.manualInstall', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}});
- expect(controller.get('manualInstall')).to.equal(true);
- controller.toggleProperty('content.installOptions.manualInstall');
- expect(controller.get('manualInstall')).to.equal(false);
- });
- });
+ App.TestAliases.testAsComputedAlias(getController(), 'manualInstall', 'content.installOptions.manualInstall', 'boolean');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'sshKey', 'content.installOptions.sshKey', 'string');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'sshUser', 'content.installOptions.sshUser', 'string');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'sshPort', 'content.installOptions.sshPort', 'string');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'agentUser', 'content.installOptions.agentUser', 'string');
describe('#hostNames', function() {
it('should be equal to content.installOptions.hostNames', function() {
@@ -86,52 +83,7 @@ describe('App.WizardStep2Controller', function () {
});
});
- describe('#sshKey', function() {
- it('should be equal to content.installOptions.sshKey', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {sshKey: '123'}}});
- expect(controller.get('sshKey')).to.equal('123');
- controller.set('content.installOptions.sshKey', '321');
- expect(controller.get('sshKey')).to.equal('321');
- });
- });
-
- describe('#sshUser', function() {
- it('should be equal to content.installOptions.sshUser', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {sshUser: '123'}}});
- expect(controller.get('sshUser')).to.equal('123');
- controller.set('content.installOptions.sshUser', '321');
- expect(controller.get('sshUser')).to.equal('321');
- });
- });
-
- describe('#sshPort', function() {
- it('should be equal to content.installOptions.sshPort', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {sshPort: '123'}}});
- expect(controller.get('sshPort')).to.equal('123');
- controller.set('content.installOptions.sshPort', '321');
- expect(controller.get('sshPort')).to.equal('321');
- });
- });
-
- describe('#agentUser', function() {
- it('should be equal to content.installOptions.agentUser', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {agentUser: '123'}}});
- expect(controller.get('agentUser')).to.equal('123');
- controller.set('content.installOptions.agentUser', '321');
- expect(controller.get('agentUser')).to.equal('321');
- });
- });
-
- describe('#installType', function() {
- it('should be manualDriven if manualInstall is selected', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}});
- expect(controller.get('installType')).to.equal('manualDriven');
- });
- it('should be ambariDriven if manualInstall isn\'t selected', function() {
- var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: false}}});
- expect(controller.get('installType')).to.equal('ambariDriven');
- });
- });
+ App.TestAliases.testAsComputedIfThenElse(getController(), 'installType', 'manualInstall', 'manualDriven', 'ambariDriven');
describe('#updateHostNameArr()', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 f48514c..a699dcc 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -25,16 +25,20 @@ require('utils/http_client');
require('models/host');
require('controllers/wizard/step3_controller');
+function getController() {
+ return App.WizardStep3Controller.create({
+ content: Em.Object.create({installedHosts: Em.A([]), installOptions: {}, controllerName: ''}),
+ wizardController: App.InstallerController.create(),
+ setRegistrationInProgressOnce: Em.K,
+ disablePreviousSteps: Em.K
+ });
+}
+
describe('App.WizardStep3Controller', function () {
beforeEach(function () {
- c = App.WizardStep3Controller.create({
- content: Em.Object.create({installedHosts: Em.A([]), installOptions: {}}),
- wizardController: App.InstallerController.create(),
- setRegistrationInProgressOnce: Em.K,
- disablePreviousSteps: Em.K
- });
+ c = getController();
sinon.stub(App.db, 'getDisplayLength', Em.K);
sinon.stub(App.db, 'getFilterConditions').returns([]);
@@ -47,6 +51,12 @@ describe('App.WizardStep3Controller', function () {
App.db.getFilterConditions.restore();
});
+ App.TestAliases.testAsComputedGt(getController(), 'isHostHaveWarnings', 'warnings.length', 0);
+
+ App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController');
+
+ App.TestAliases.testAsComputedIfThenElse(getController(), 'registrationTimeoutSecs', 'content.installOptions.manualInstall', 15, 120);
+
describe('#getAllRegisteredHostsCallback', function () {
it('One host is already in the cluster, one host is registered', function () {
@@ -137,47 +147,6 @@ describe('App.WizardStep3Controller', function () {
});
- describe('#registrationTimeoutSecs', function () {
-
- it('Manual install', function () {
- c.set('content.installOptions.manualInstall', true);
- expect(c.get('registrationTimeoutSecs')).to.equal(15);
- });
-
- it('Not manual install', function () {
- c.set('content.installOptions.manualInstall', false);
- expect(c.get('registrationTimeoutSecs')).to.equal(120);
- });
-
- });
-
- describe('#isHostHaveWarnings', function () {
-
- var tests = [
- {
- warnings: [
- {},
- {}
- ],
- m: 'Warnings exist',
- e: true
- },
- {
- warnings: [],
- m: 'Warnings don\'t exist',
- e: false
- }
- ];
-
- tests.forEach(function (test) {
- it(test.m, function () {
- c.set('warnings', test.warnings);
- expect(c.get('isHostHaveWarnings')).to.equal(test.e);
- });
- });
-
- });
-
describe('#isWarningsBoxVisible', function () {
afterEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 b2524e4..056c30a 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -44,44 +44,42 @@ var controller,
isSelected: true
})
];
-describe('App.WizardStep6Controller', function () {
- beforeEach(function () {
- controller = App.WizardStep6Controller.create();
- controller.set('content', Em.Object.create({
+function getController() {
+ var controller = App.WizardStep6Controller.create({
+ content: Em.Object.create({
hosts: {},
masterComponentHosts: {},
- services: services
- }));
+ services: services,
+ controllerName: ''
+ })
+ });
- var h = {}, m = [];
- Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) {
- var obj = Em.Object.create({
- name: hostName,
- hostName: hostName,
- bootStatus: 'REGISTERED'
- });
- h[hostName] = obj;
- m.push(obj);
+ var h = {}, m = [];
+ Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) {
+ var obj = Em.Object.create({
+ name: hostName,
+ hostName: hostName,
+ bootStatus: 'REGISTERED'
});
+ h[hostName] = obj;
+ m.push(obj);
+ });
- controller.set('content.hosts', h);
- controller.set('content.masterComponentHosts', m);
- controller.set('isMasters', false);
+ controller.set('content.hosts', h);
+ controller.set('content.masterComponentHosts', m);
+ controller.set('isMasters', false);
+ return controller;
+}
- });
+describe('App.WizardStep6Controller', function () {
- describe('#isAddHostWizard', function () {
- it('true if content.controllerName is addHostController', function () {
- controller.set('content.controllerName', 'addHostController');
- expect(controller.get('isAddHostWizard')).to.equal(true);
- });
- it('false if content.controllerName is not addHostController', function () {
- controller.set('content.controllerName', 'mainController');
- expect(controller.get('isAddHostWizard')).to.equal(false);
- });
+ beforeEach(function () {
+ controller = getController();
});
+ App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController');
+
describe('#installedServiceNames', function () {
it(' should filter content.services by isInstalled property', function () {
var services = Em.A([]);
@@ -348,27 +346,9 @@ describe('App.WizardStep6Controller', function () {
});
});
- describe('#isInstallerWizard', function () {
- it('true if content.controllerName is addHostController', function () {
- controller.set('content.controllerName', 'installerController');
- expect(controller.get('isInstallerWizard')).to.equal(true);
- });
- it('false if content.controllerName is not addHostController', function () {
- controller.set('content.controllerName', 'mainController');
- expect(controller.get('isInstallerWizard')).to.equal(false);
- });
- });
+ App.TestAliases.testAsComputedEqual(getController(), 'isInstallerWizard', 'content.controllerName', 'installerController');
- describe('#isAddServiceWizard', function () {
- it('true if content.controllerName is addServiceController', function () {
- controller.set('content.controllerName', 'addServiceController');
- expect(controller.get('isAddServiceWizard')).to.equal(true);
- });
- it('false if content.controllerName is not addServiceController', function () {
- controller.set('content.controllerName', 'mainController');
- expect(controller.get('isAddServiceWizard')).to.equal(false);
- });
- });
+ App.TestAliases.testAsComputedEqual(getController(), 'isAddServiceWizard', 'content.controllerName', 'addServiceController');
describe('#selectClientHost', function () {
it('true if isClientsSet false', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 35b7a5b..4d43a09 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -96,23 +96,31 @@ var installerStep7Controller,
controller.get('filterColumns').findProperty('attributeName', 'hasIssues').set('selected', testCase.isIssuesFilterActive);
};
+function getController() {
+ return App.WizardStep7Controller.create({
+ content: Em.Object.create({
+ services: [],
+ advancedServiceConfig: [],
+ serviceConfigProperties: []
+ })
+ });
+}
+
describe('App.InstallerStep7Controller', function () {
beforeEach(function () {
sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
- installerStep7Controller = App.WizardStep7Controller.create({
- content: Em.Object.create({
- services: [],
- advancedServiceConfig: [],
- serviceConfigProperties: []
- })
- });
+ installerStep7Controller = getController();
});
afterEach(function() {
App.config.setPreDefinedServiceConfigs.restore();
});
+ App.TestAliases.testAsComputedAlias(getController(), 'masterComponentHosts', 'content.masterComponentHosts', 'array');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'slaveComponentHosts', 'content.slaveGroupProperties', 'array');
+
describe('#installedServiceNames', function () {
var tests = Em.A([
@@ -248,30 +256,6 @@ describe('App.InstallerStep7Controller', function () {
});
});
- describe('#masterComponentHosts', function () {
- it('should be equal to content.masterComponentHosts', function () {
- var masterComponentHosts = [
- {},
- {},
- {}
- ];
- installerStep7Controller.reopen({content: {masterComponentHosts: masterComponentHosts}});
- expect(installerStep7Controller.get('masterComponentHosts')).to.eql(masterComponentHosts);
- });
- });
-
- describe('#slaveComponentHosts', function () {
- it('should be equal to content.slaveGroupProperties', function () {
- var slaveGroupProperties = [
- {},
- {},
- {}
- ];
- installerStep7Controller.reopen({content: {slaveGroupProperties: slaveGroupProperties}});
- expect(installerStep7Controller.get('slaveComponentHosts')).to.eql(slaveGroupProperties);
- });
- });
-
describe('#_createSiteToTagMap', function () {
it('should return filtered map', function () {
var desired_configs = {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index 71d1e48..0e120a2 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -23,42 +23,47 @@ require('controllers/main/service/info/configs');
require('controllers/wizard/step8_controller');
var installerStep8Controller, configurationController;
-describe('App.WizardStep8Controller', function () {
+var configs = Em.A([
+ Em.Object.create({filename: 'hdfs-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'hdfs-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'hue-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'hue-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'mapred-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'mapred-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'yarn-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'yarn-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'hbase-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'hbase-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'oozie-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'oozie-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'hive-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'hive-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'pig-properties.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'webhcat-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'webhcat-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'tez-site.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'tez-site.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'}),
+ Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p1', value: 'v1'}),
+ Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'})
+]);
+
+function getController() {
+ return App.WizardStep8Controller.create({
+ configs: configs,
+ content: {controllerName: ''}
+ });
+}
- var configs = Em.A([
- Em.Object.create({filename: 'hdfs-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'hdfs-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'hue-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'hue-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'mapred-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'mapred-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'yarn-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'yarn-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'hbase-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'hbase-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'oozie-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'oozie-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'hive-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'hive-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'pig-properties.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'webhcat-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'webhcat-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'tez-site.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'tez-site.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'}),
- Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p1', value: 'v1'}),
- Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'})
- ]);
+describe('App.WizardStep8Controller', function () {
beforeEach(function () {
- installerStep8Controller = App.WizardStep8Controller.create({
- configs: configs
- });
+ installerStep8Controller = getController();
configurationController = App.MainServiceInfoConfigsController.create({});
});
@@ -92,6 +97,12 @@ describe('App.WizardStep8Controller', function () {
});
});
+ App.TestAliases.testAsComputedFilterBy(getController(), 'installedServices', 'content.services', 'isInstalled', true);
+
+ App.TestAliases.testAsComputedEqual(getController(), 'isManualKerberos', 'App.router.mainAdminKerberosController.kdc_type', 'none');
+
+ App.TestAliases.testAsComputedAlias(getController(), 'clusterName', 'content.cluster.name', 'string');
+
describe('#createSelectedServicesData', function () {
var tests = Em.A([
@@ -228,13 +239,6 @@ describe('App.WizardStep8Controller', function () {
});
- describe('#clusterName', function () {
- it('should be equal to content.cluster.name', function () {
- installerStep8Controller.set('content', {cluster: {name: 'new_name'}});
- expect(installerStep8Controller.get('clusterName')).to.equal('new_name');
- });
- });
-
describe('#createCoreSiteObj', function () {
it('should return config', function () {
var content = Em.Object.create({
@@ -1887,17 +1891,7 @@ describe('App.WizardStep8Controller', function () {
});
- describe('#isAllClusterDeleteRequestsCompleted', function () {
- it('should depend on completed cluster delete requests number', function () {
- installerStep8Controller.setProperties({
- clusterDeleteRequestsCompleted: 0,
- clusterNames: ['c0']
- });
- expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.false;
- installerStep8Controller.incrementProperty('clusterDeleteRequestsCompleted');
- expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedEqualProperties(getController(), 'isAllClusterDeleteRequestsCompleted', 'clusterDeleteRequestsCompleted', 'clusterNames.length');
describe('#deleteClusterSuccessCallback', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 fabdc2d..fc52920 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -29,27 +29,32 @@ require('utils/ajax/ajax');
var modelSetup = require('test/init_model_test');
var c, obj;
+
+function getController() {
+ return App.WizardStep9Controller.create({
+ content: {controllerName: '', cluster: {status: ''}},
+ saveClusterStatus: Em.K,
+ saveInstalledHosts: Em.K,
+ togglePreviousSteps: Em.K,
+ setFinishState: Em.K,
+ changeParseHostInfo: Em.K,
+ parseHostInfoPolling: Em.K,
+ wizardController: Em.Object.create({
+ requestsId: [],
+ cluster: {oldRequestsId: []},
+ getDBProperty: function(name) {
+ return this.get(name);
+ }
+ })
+ });
+}
+
describe('App.InstallerStep9Controller', function () {
beforeEach(function () {
App.set('supports.skipComponentStartAfterInstall', false);
modelSetup.setupStackServiceComponent();
- c = App.WizardStep9Controller.create({
- content: {controllerName: ''},
- saveClusterStatus: Em.K,
- saveInstalledHosts: Em.K,
- togglePreviousSteps: Em.K,
- setFinishState: Em.K,
- changeParseHostInfo: Em.K,
- parseHostInfoPolling: Em.K,
- wizardController: Em.Object.create({
- requestsId: [],
- cluster: {oldRequestsId: []},
- getDBProperty: function(name) {
- return this.get(name);
- }
- })
- });
+ c = getController();
obj = App.InstallerController.create();
sinon.stub(App.ajax, 'send', function() {
return {
@@ -72,6 +77,8 @@ describe('App.InstallerStep9Controller', function () {
App.ajax.send.restore();
});
+ App.TestAliases.testAsComputedEqual(getController(), 'showRetry', 'content.cluster.status', 'INSTALL FAILED');
+
describe('#isSubmitDisabled', function () {
var tests = Em.A([
{controllerName: 'addHostController', state: 'STARTED', e: false},
@@ -181,17 +188,6 @@ describe('App.InstallerStep9Controller', function () {
});
});
- describe('#showRetry', function () {
- it('cluster status is not INSTALL FAILED', function () {
- c.reopen({content: {cluster: {status: 'INSTALLED'}}});
- expect(c.get('showRetry')).to.equal(false);
- });
- it('cluster status is INSTALL FAILED', function () {
- c.reopen({content: {cluster: {status: 'INSTALL FAILED'}}});
- expect(c.get('showRetry')).to.equal(true);
- });
- });
-
describe('#resetHostsForRetry', function () {
it('All should have status "pending" and message "Waiting"', function () {
var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/authentication_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/authentication_test.js b/ambari-web/test/models/authentication_test.js
index 3e7f44d..f0002cd 100644
--- a/ambari-web/test/models/authentication_test.js
+++ b/ambari-web/test/models/authentication_test.js
@@ -63,6 +63,10 @@ describe('App.AuthenticationForm', function () {
});
});
+ App.TestAliases.testAsComputedIfThenElse(App.AuthenticationForm.create(), 'testConfigurationMessage', 'testResult', Em.I18n.t('admin.authentication.form.test.success'), Em.I18n.t('admin.authentication.form.test.fail'));
+
+ App.TestAliases.testAsComputedIfThenElse(App.AuthenticationForm.create(), 'testConfigurationClass', 'testResult', 'text-success', 'text-error');
+
describe('#testResult', function () {
it('should be 0 or 1', function () {
form.testConfiguration();
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/cluster_states_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/cluster_states_test.js b/ambari-web/test/models/cluster_states_test.js
index f114b3d..3f12d9f 100644
--- a/ambari-web/test/models/cluster_states_test.js
+++ b/ambari-web/test/models/cluster_states_test.js
@@ -45,18 +45,7 @@ var compressedResponse = LZString.compressToBase64(JSON.stringify(response2));
describe('App.clusterStatus', function () {
- describe('#isInstalled', function () {
- notInstalledStates.forEach(function (item) {
- it('should be false', function () {
- status.set('clusterState', item);
- expect(status.get('isInstalled')).to.be.false;
- });
- });
- it('should be true', function () {
- status.set('clusterState', 'DEFAULT');
- expect(status.get('isInstalled')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedNotExistsIn(status, 'isInstalled', 'clusterState', notInstalledStates);
describe('#value', function () {
it('should be set from properties', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/configs/objects/service_config_category_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_category_test.js b/ambari-web/test/models/configs/objects/service_config_category_test.js
index 33521fe..87e1616 100644
--- a/ambari-web/test/models/configs/objects/service_config_category_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_category_test.js
@@ -1,4 +1,3 @@
-
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -104,12 +103,18 @@ var serviceConfigCategory,
]
};
+function getCategory() {
+ return App.ServiceConfigCategory.create();
+}
+
describe('App.ServiceConfigCategory', function () {
beforeEach(function () {
- serviceConfigCategory = App.ServiceConfigCategory.create();
+ serviceConfigCategory = getCategory();
});
+ App.TestAliases.testAsComputedSumProperties(getCategory(), 'errorCount', ['slaveErrorCount', 'nonSlaveErrorCount']);
+
describe('#primaryName', function () {
nameCases.forEach(function (item) {
it('should return ' + item.primary, function () {
@@ -156,19 +161,6 @@ describe('App.ServiceConfigCategory', function () {
});
});
- describe('#errorCount', function () {
- it('should sum all errors for category', function () {
- serviceConfigCategory.reopen({
- slaveErrorCount: 1
- });
- expect(serviceConfigCategory.get('errorCount')).to.equal(1);
- serviceConfigCategory.set('nonSlaveErrorCount', 2);
- expect(serviceConfigCategory.get('errorCount')).to.equal(3);
- serviceConfigCategory.set('slaveErrorCount', 0);
- expect(serviceConfigCategory.get('errorCount')).to.equal(2);
- });
- });
-
describe('#isAdvanced', function () {
it('should be true', function () {
serviceConfigCategory.set('name', 'Advanced');
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 0421ab4..11ea4ab 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -321,12 +321,18 @@ var serviceConfigProperty,
}
];
+function getProperty() {
+ return App.ServiceConfigProperty.create();
+}
+
describe('App.ServiceConfigProperty', function () {
beforeEach(function () {
- serviceConfigProperty = App.ServiceConfigProperty.create();
+ serviceConfigProperty = getProperty();
});
+ App.TestAliases.testAsComputedFirstNotBlank(getProperty(), 'placeholder', ['placeholderText', 'savedValue']);
+
describe('#overrideErrorTrigger', function () {
it('should be an increment', function () {
serviceConfigProperty.set('overrides', configsData[0].overrides);
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/configs/section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/section_test.js b/ambari-web/test/models/configs/section_test.js
index 967534e..3c9ab40 100644
--- a/ambari-web/test/models/configs/section_test.js
+++ b/ambari-web/test/models/configs/section_test.js
@@ -19,10 +19,14 @@
var App = require('app');
var model;
+function getModel() {
+ return App.Section.createRecord();
+}
+
describe('App.Section', function () {
beforeEach(function () {
- model = App.Section.createRecord();
+ model = getModel();
});
describe('#errorsCount', function () {
@@ -46,54 +50,6 @@ describe('App.Section', function () {
});
- describe('#isHiddenByFilter', function () {
-
- Em.A([
- {
- subSections: [],
- m: 'no subsections',
- e: true
- },
- {
- subSections: [
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})]}),
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})]})
- ],
- m: 'no subsections are hidden',
- e: false
- },
- {
- subSections: [
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: false, hiddenBySection: false}), Em.Object.create({isHiddenByFilter: true, isVisible: true, hiddenBySection: true})]})
- ],
- m: 'no subsections are hidden (hiddenBySection)',
- e: false
- },
- {
- subSections: [
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})]}),
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})]})
- ],
- m: 'one subsection is hidden',
- e: false
- },
- {
- subSections: [
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})]}),
- App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})]})
- ],
- m: 'all subsections are hidden',
- e: true
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- model.reopen({
- subSections: test.subSections
- });
- expect(model.get('isHiddenByFilter')).to.equal(test.e);
- });
- });
-
- });
+ App.TestAliases.testAsComputedEveryBy(getModel(), 'isHiddenByFilter', 'subSections', 'isSectionVisible', false);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 6ba6fb0..ef68fb6 100644
--- a/ambari-web/test/models/host_component_test.js
+++ b/ambari-web/test/models/host_component_test.js
@@ -27,15 +27,6 @@ describe('App.HostComponent', function() {
});
var hc = App.HostComponent.find('COMP_host');
-
- describe('#getStatusesList', function() {
- it('allowed statuses', function() {
- var statuses = ["STARTED","STARTING","INSTALLED","STOPPING","INSTALL_FAILED","INSTALLING","UPGRADE_FAILED","UNKNOWN","DISABLED","INIT"];
- expect(App.HostComponentStatus.getStatusesList()).to.include.members(statuses);
- expect(statuses).to.include.members(App.HostComponentStatus.getStatusesList());
- });
- });
-
describe('#getStatusesList', function() {
it('allowed statuses', function() {
var statuses = ["STARTED","STARTING","INSTALLED","STOPPING","INSTALL_FAILED","INSTALLING","UPGRADE_FAILED","UNKNOWN","DISABLED","INIT"];
@@ -94,29 +85,9 @@ describe('App.HostComponent', function() {
});
});
- describe('#isRunning', function() {
- var testCases = [
- {
- workStatus: 'INSTALLED',
- result: false
- },
- {
- workStatus: 'STARTING',
- result: true
- },
- {
- workStatus: 'STARTED',
- result: true
- }
- ];
- testCases.forEach(function(test){
- it('workStatus - ' + test.workStatus, function() {
- hc.set('workStatus', test.workStatus);
- hc.propertyDidChange('isRunning');
- expect(hc.get('isRunning')).to.equal(test.result);
- });
- });
- });
+ App.TestAliases.testAsComputedIfThenElse(hc, 'passiveTooltip', 'isActive', '', Em.I18n.t('hosts.component.passive.mode'));
+
+ App.TestAliases.testAsComputedExistsIn(hc, 'isRunning', 'workStatus', ['STARTED', 'STARTING']);
describe('#isDecommissioning', function() {
var mock = [];
@@ -157,6 +128,10 @@ describe('App.HostComponent', function() {
});
});
+ App.TestAliases.testAsComputedEqual(hc, 'isActive', 'passiveState', 'OFF');
+
+ App.TestAliases.testAsComputedIfThenElse(hc, 'passiveTooltip', 'isActive', '', Em.I18n.t('hosts.component.passive.mode'));
+
describe('#isActive', function() {
it('passiveState is ON', function() {
hc.set('passiveState', "ON");
@@ -315,28 +290,6 @@ describe('App.HostComponent', function() {
});
});
- describe('#isNotInstalled', function () {
-
- Em.A([
- {
- p: {workStatus: 'INIT'},
- e: true
- },
- {
- p: {workStatus: 'INSTALL_FAILED'},
- e: true
- },
- {
- p: {workStatus: 'STARTED'},
- e: false
- }
- ]).forEach(function (test, index) {
- it('#' + (index + 1), function() {
- hc.setProperties(test.p);
- expect(hc.get('isNotInstalled')).to.equal(test.e);
- });
- });
-
- });
+ App.TestAliases.testAsComputedExistsIn(hc, 'isNotInstalled', 'workStatus', ['INIT', 'INSTALL_FAILED']);
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 30bc5e2..9642c41 100644
--- a/ambari-web/test/models/host_test.js
+++ b/ambari-web/test/models/host_test.js
@@ -52,16 +52,25 @@ describe('App.Host', function () {
last_heart_beat_time: (new Date()).getTime()
}
];
+
before(function() {
App.set('testMode', false);
});
+
App.Host.reopen({
hostComponents: []
});
+
App.store.loadMany(App.Host, data);
var host1 = App.Host.find('host1');
+ App.TestAliases.testAsComputedAlias(host1, 'componentsInPassiveStateCount', 'componentsInPassiveState.length', 'number');
+
+ App.TestAliases.testAsComputedAlias(host1, 'componentsWithStaleConfigsCount', 'componentsWithStaleConfigs.length', 'number');
+
+ App.TestAliases.testAsComputedAlias(host1, 'disksMounted', 'diskInfo.length', 'number');
+
describe('#diskUsedFormatted', function () {
it('host1 - 10GB ', function () {
@@ -460,4 +469,5 @@ describe('App.Host', function () {
});
});
});
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/repository_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/repository_test.js b/ambari-web/test/models/repository_test.js
index 2c65907..d3a2875 100644
--- a/ambari-web/test/models/repository_test.js
+++ b/ambari-web/test/models/repository_test.js
@@ -20,14 +20,24 @@ var App = require('app');
require('models/repository');
+function getModel() {
+ return App.Repository.createRecord();
+}
+
describe('App.Repository', function () {
var model;
beforeEach(function () {
- model = App.Repository.createRecord();
+ model = getModel();
});
+ App.TestAliases.testAsComputedNotEqualProperties(getModel(), 'undo', 'baseUrl', 'latestBaseUrl');
+
+ App.TestAliases.testAsComputedAlias(getModel(), 'isSelected', 'operatingSystem.isSelected', 'boolean');
+
+ App.TestAliases.testAsComputedAlias(getModel(), 'clearAll', 'baseUrl', 'string'); // string??
+
describe('#invalidFormatError', function () {
var cases = [
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/stack_service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/stack_service_test.js b/ambari-web/test/models/stack_service_test.js
index 8299cce..0d3fdf6 100644
--- a/ambari-web/test/models/stack_service_test.js
+++ b/ambari-web/test/models/stack_service_test.js
@@ -212,18 +212,7 @@ describe('App.StackService', function () {
});
});
- describe('#isClientOnlyService', function () {
- it('Has not only client serviceComponents', function () {
- ss.set('serviceComponents', [Em.Object.create({isSlave: true}), Em.Object.create({isClient: true})]);
- ss.propertyDidChange('isClientOnlyService');
- expect(ss.get('isClientOnlyService')).to.be.false;
- });
- it('Has only client serviceComponents', function () {
- ss.set('serviceComponents', [Em.Object.create({isClient: true})]);
- ss.propertyDidChange('isClientOnlyService');
- expect(ss.get('isClientOnlyService')).to.be.true;
- });
- });
+ App.TestAliases.testAsComputedEveryBy(ss, 'isClientOnlyService', 'serviceComponents', 'isClient', true);
describe('#isNoConfigTypes', function () {
it('configTypes is null', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/upgrade_entity_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/upgrade_entity_test.js b/ambari-web/test/models/upgrade_entity_test.js
index 0aa9248c..38fa093 100644
--- a/ambari-web/test/models/upgrade_entity_test.js
+++ b/ambari-web/test/models/upgrade_entity_test.js
@@ -19,13 +19,19 @@
var App = require('app');
require('models/upgrade_entity');
+function getModel() {
+ return App.upgradeEntity.create();
+}
+
describe('App.upgradeEntity', function () {
var model;
beforeEach(function () {
- model = App.upgradeEntity.create();
+ model = getModel();
});
+ App.TestAliases.testAsComputedNotEqual(getModel(), 'isVisible', 'status', 'PENDING');
+
describe("#isRunning", function() {
it("status IN_PROGRESS", function() {
model.set('status', 'IN_PROGRESS');
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/user_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/user_test.js b/ambari-web/test/models/user_test.js
index 607f4dd..4a3a48d 100644
--- a/ambari-web/test/models/user_test.js
+++ b/ambari-web/test/models/user_test.js
@@ -28,16 +28,22 @@ var user,
id: 'user'
};
+function getUser() {
+ return App.User.createRecord(userData);
+}
+
describe('App.User', function () {
beforeEach(function () {
- user = App.User.createRecord(userData);
+ user = getUser();
});
afterEach(function () {
modelSetup.deleteRecord(user);
});
+ App.TestAliases.testAsComputedAlias(getUser(), 'id', 'userName', 'string');
+
describe('#id', function () {
it('should take value from userName', function () {
user.set('userName', 'name');
@@ -57,27 +63,17 @@ describe('App.User', function () {
});
});
+function getForm() {
+ return App.CreateUserForm.create();
+}
+
describe('App.CreateUserForm', function () {
beforeEach(function () {
- form = App.CreateUserForm.create();
+ form = getForm();
});
- describe('#object', function () {
-
- before(function () {
- sinon.stub(App, 'get').withArgs('router.mainAdminUserCreateController.content').returns(userData);
- });
-
- after(function () {
- App.get.restore();
- });
-
- it('should take data from controller', function () {
- expect(form.get('object')).to.eql(userData);
- });
-
- });
+ App.TestAliases.testAsComputedAlias(getForm(), 'object', 'App.router.mainAdminUserCreateController.content', 'object');
describe('#field.userName.toLowerCase', function () {
it('should convert userName into lower case', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 8d76946..ab3383e 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
@@ -31,6 +31,8 @@ describe.skip('App.ConfigHistoryFlowView', function () {
serviceVersions: []
});
+ App.TestAliases.testAsComputedAlias(view, 'serviceName', 'controller.selectedService.serviceName', 'string');
+
describe('#isSaveDisabled', function () {
var testCases = [
{
@@ -725,3 +727,15 @@ describe.skip('App.ConfigHistoryFlowView', function () {
});
});
});
+
+function getView() {
+ return App.ConfigsServiceVersionBoxView.create();
+}
+
+describe('App.ConfigsServiceVersionBoxView', function () {
+
+ App.TestAliases.testAsComputedAlias(getView(), 'disabledActionAttr', 'serviceVersion.disabledActionAttr', 'object');
+
+ App.TestAliases.testAsComputedAlias(getView(), 'disabledActionMessages', 'serviceVersion.disabledActionMessages', 'object');
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js b/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js
index 0cf2992..ce0dd39 100644
--- a/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js
+++ b/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js
@@ -20,24 +20,30 @@ var App = require('app');
require('views/common/configs/custom_category_views/notification_configs_view');
var view;
+function getView() {
+ return App.NotificationsConfigsView.create({
+ $: function() {
+ return {show: Em.K, hide: Em.K};
+ },
+ category: {
+ name: 'name'
+ },
+ serviceConfigs: [],
+ parentView: Em.View.create({
+ filter: '',
+ columns: []
+ })
+ });
+}
+
describe('App.NotificationsConfigsView', function () {
beforeEach(function () {
- view = App.NotificationsConfigsView.create({
- $: function() {
- return {show: Em.K, hide: Em.K};
- },
- category: {
- name: 'name'
- },
- serviceConfigs: [],
- parentView: Em.View.create({
- filter: '',
- columns: []
- })
- });
+ view = getView();
});
+ App.TestAliases.testAsComputedFindBy(getView(), 'useAuthConfig', 'categoryConfigs', 'name', 'smtp_use_auth');
+
describe('#didInsertElement', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
index 59ac49c..167c007 100644
--- a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
+++ b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
@@ -94,6 +94,8 @@ describe('App.ServiceConfigsByCategoryView', function () {
}
];
+ App.TestAliases.testAsComputedIfThenElse(view, 'isCategoryBodyVisible', 'category.isCollapsed', 'display: none;', 'display: block;');
+
describe('#sortByIndex', function () {
testData.forEach(function(_test){
it(_test.title, function () {
@@ -402,4 +404,5 @@ describe('App.ServiceConfigsByCategoryView', function () {
});
});
});
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
index 76b6763..6addbed 100644
--- a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
+++ b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
@@ -21,17 +21,27 @@ var credentialUtils = require('utils/credentials');
var view;
+function getView() {
+ return App.ManageCredentialsFormView.create({
+ parentView: Em.Object.create({})
+ });
+}
+
describe('#App.ManageCredentialsFormView', function() {
beforeEach(function() {
- view = App.ManageCredentialsFormView.create({
- parentView: Em.Object.create({})
- });
+ view = getView();
});
afterEach(function() {
view.destroy();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'storePersisted', 'App.isCredentialStorePersistent', 'boolean');
+
+ App.TestAliases.testAsComputedIfThenElse(getView(), 'formHeader', 'isRemovable', Em.I18n.t('admin.kerberos.credentials.form.header.stored'), Em.I18n.t('admin.kerberos.credentials.form.header.not.stored'));
+
+ App.TestAliases.testAsComputedIfThenElse(getView(), 'hintMessage', 'storePersisted', Em.I18n.t('admin.kerberos.credentials.store.hint.supported'), Em.I18n.t('admin.kerberos.credentials.store.hint.not.supported'));
+
describe('#prepareContent', function() {
[
{
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/table_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/table_view_test.js b/ambari-web/test/views/common/table_view_test.js
index ab7c89b..50a5ee3 100644
--- a/ambari-web/test/views/common/table_view_test.js
+++ b/ambari-web/test/views/common/table_view_test.js
@@ -24,6 +24,10 @@ require('mixins');
require('mixins/common/userPref');
require('views/common/table_view');
+function getView() {
+ return App.TableView.create();
+}
+
describe('App.TableView', function () {
var view;
@@ -38,6 +42,10 @@ describe('App.TableView', function () {
App.db.setFilterConditions.restore();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'filteredCount', 'filteredContent.length', 'number');
+
+ App.TestAliases.testAsComputedAlias(getView(), 'totalCount', 'content.length', 'number');
+
describe('#init', function() {
it('should set filterConditions on instance', function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 6134f80..c3202f6 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
@@ -54,16 +54,6 @@ describe('App.HighAvailabilityWizardStep4View', function () {
});
});
- describe("#nnCheckPointText", function() {
- it("isNextEnabled true", function() {
- view.set('controller.isNextEnabled', true);
- view.propertyDidChange('nnCheckPointText');
- expect(view.get('nnCheckPointText')).to.equal(Em.I18n.t('admin.highAvailability.wizard.step4.ckCreated'));
- });
- it("isNextEnabled false", function() {
- view.set('controller.isNextEnabled', false);
- view.propertyDidChange('nnCheckPointText');
- expect(view.get('nnCheckPointText')).to.equal(Em.I18n.t('admin.highAvailability.wizard.step4.ckNotCreated'));
- });
- });
+ App.TestAliases.testAsComputedIfThenElse(view, 'nnCheckPointText', 'controller.isNextEnabled', Em.I18n.t('admin.highAvailability.wizard.step4.ckCreated'), Em.I18n.t('admin.highAvailability.wizard.step4.ckNotCreated'));
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/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 bc50a51..a9fdfed 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,8 @@ describe('App.upgradeWizardView', function () {
});
view.removeObserver('App.clusterName', view, 'startPolling');
+ App.TestAliases.testAsComputedEqualProperties(view, 'isFinalizeItem', 'manualItem.context', 'controller.finalizeContext');
+
describe("#upgradeGroups", function () {
it("upgradeGroups is null", function () {
view.set('controller.upgradeData.upgradeGroups', null);
@@ -434,18 +436,6 @@ describe('App.upgradeWizardView', function () {
});
});
- describe("#isFinalizeItem", function () {
- it("depends of manualItem.context", function () {
- view.reopen({
- manualItem: {
- context: 'Confirm Finalize'
- }
- });
- view.propertyDidChange('isFinalizeItem');
- expect(view.get('isFinalizeItem')).to.be.true;
- });
- });
-
describe("#toggleDetails()", function () {
before(function () {
sinon.stub(view, 'toggleProperty', Em.K);
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/alert_definitions_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alert_definitions_view_test.js b/ambari-web/test/views/main/alert_definitions_view_test.js
index ad62856..66d1188 100644
--- a/ambari-web/test/views/main/alert_definitions_view_test.js
+++ b/ambari-web/test/views/main/alert_definitions_view_test.js
@@ -22,10 +22,14 @@ require('views/main/alert_definitions_view');
var view;
+function getView() {
+ return App.MainAlertDefinitionsView.create({});
+}
+
describe('App.MainAlertDefinitionsView', function () {
beforeEach(function () {
- view = App.MainAlertDefinitionsView.create({});
+ view = getView();
sinon.stub(App.db, 'setFilterConditions', Em.K);
sinon.stub(App.db, 'getFilterConditions', Em.K);
sinon.stub(App.db, 'getDisplayLength', Em.K);
@@ -41,6 +45,8 @@ describe('App.MainAlertDefinitionsView', function () {
view.initFilters.restore();
});
+ App.TestAliases.testAsComputedAlias(getView(), 'totalCount', 'content.length', 'number');
+
describe('#serviceFilterView', function () {
it('Add Ambari service to filters', function () {
var serviceFilterClass = view.serviceFilterView;
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js
index 645856a..3c91949 100644
--- a/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js
+++ b/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js
@@ -20,14 +20,16 @@ var App = require('app');
var view;
+function getView() {
+ return App.MainAlertsManageAlertGroupView.create({
+ controller: Em.Object.create()
+ });
+}
+
describe('App.MainAlertsManageAlertGroupView', function () {
beforeEach(function () {
-
- view = App.MainAlertsManageAlertGroupView.create({
- controller: Em.Object.create()
- });
-
+ view = getView();
});
it('#buttonObserver', function () {
@@ -89,4 +91,6 @@ describe('App.MainAlertsManageAlertGroupView', function () {
});
+ App.TestAliases.testAsComputedIfThenElse(getView(), 'removeButtonTooltip', 'controller.isRemoveButtonDisabled', Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButtonDisabled'), Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButton'))
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js b/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
index 932ff87..6fc484f 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js
@@ -23,6 +23,10 @@ require('views/main/dashboard/widgets/hbase_average_load');
require('views/main/dashboard/widgets/text_widget');
require('views/main/dashboard/widget');
+function getView() {
+ return App.HBaseAverageLoadView.create({model_type: null});
+}
+
describe('App.HBaseAverageLoadView', function() {
var tests = [
@@ -100,4 +104,10 @@ describe('App.HBaseAverageLoadView', function() {
});
});
+ App.TestAliases.testAsComputedAlias(getView(), 'data', 'model.averageLoad', 'number');
+
+ App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2');
+
+ App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1');
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
index 80a292b..3615ccc 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js
@@ -22,6 +22,10 @@ require('views/main/dashboard/widgets/hbase_regions_in_transition');
require('views/main/dashboard/widgets/text_widget');
require('views/main/dashboard/widget');
+function getView() {
+ return App.HBaseRegionsInTransitionView.create({model_type:null});
+}
+
describe('App.HBaseRegionsInTransitionView', function() {
var tests = [
@@ -99,4 +103,10 @@ describe('App.HBaseRegionsInTransitionView', function() {
});
});
+ App.TestAliases.testAsComputedAlias(getView(), 'data', 'model.regionsInTransition', 'number');
+
+ App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2');
+
+ App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1');
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js b/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
index 992b537..96cafc4 100644
--- a/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js
@@ -23,6 +23,10 @@ require('views/main/dashboard/widgets/namenode_rpc');
require('views/main/dashboard/widgets/text_widget');
require('views/main/dashboard/widget');
+function getView() {
+ return App.NameNodeRpcView.create({model_type:null});
+}
+
describe('App.NameNodeRpcView', function() {
var tests = [
@@ -104,4 +108,8 @@ describe('App.NameNodeRpcView', function() {
});
});
+ App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2');
+
+ App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1');
+
});
[3/5] ambari git commit: AMBARI-14296. Add common tests for
Em.computed macros (onechiporenko)
Posted by on...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/init_computed_aliases.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/init_computed_aliases.js b/ambari-web/test/init_computed_aliases.js
new file mode 100644
index 0000000..030480d
--- /dev/null
+++ b/ambari-web/test/init_computed_aliases.js
@@ -0,0 +1,169 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ *
+ * @class App.TestAliases
+ */
+App.TestAliases = {
+ helpers: {
+
+ /**
+ * Get needed value (basing on <code>key</code>) from <code>self</code> or <code>App</code>
+ *
+ * @param {Ember.Object} self
+ * @param {string} key
+ * @returns {*}
+ */
+ smartGet: function (self, key) {
+ var isApp = key.startsWith('App.');
+ var name = isApp ? key.replace('App.', '') : key;
+ return isApp ? App.get(name) : self.get(name);
+ },
+
+ /**
+ * Stub <code>get</code> for <code>App</code> or <code>self</code>
+ *
+ * @param {Ember.Object} self
+ * @returns {App.TestAliases}
+ */
+ smartStubGet: function (self) {
+ var args = [].slice.call(arguments);
+ if (args.length === 3) {
+ return this._stubOneKey.apply(this, args);
+ }
+ return this._stubManyKeys.apply(this, args)
+
+ },
+
+ /**
+ * Trigger recalculation of the needed property in the <code>self</code>
+ * or in the <code>App</code> (depends on <code>propertyName</code>)
+ *
+ * @param {Ember.Object} self
+ * @param {string} propertyName
+ * @returns {App.TestAliases}
+ */
+ propertyDidChange: function (self, propertyName) {
+ var isApp = propertyName.startsWith('App.');
+ var name = isApp ? propertyName.replace('App.', '') : propertyName;
+ var context = isApp ? App : self;
+ Em.propertyDidChange(context, name);
+ return this;
+ },
+
+ /**
+ * Try to restore (@see sinon.restore) <code>get</code> for <code>App</code> and <code>context</code>
+ *
+ * @param {Ember.Object} context
+ * @returns {App.TestAliases}
+ */
+ smartRestoreGet: function(context) {
+ Em.tryInvoke(context.get, 'restore');
+ Em.tryInvoke(App.get, 'restore');
+ return this;
+ },
+
+ /**
+ * Stub <code>get</code>-method for <code>App</code> or <code>self</code> (depends on <code>dependentKey</code>)
+ * to return <code>value</code> if <code>dependentKey</code> is get
+ *
+ * @param {Ember.Object} self
+ * @param {string} dependentKey
+ * @param {*} value
+ * @returns {App.TestAliases}
+ * @private
+ */
+ _stubOneKey: function (self,dependentKey, value) {
+ var isApp = dependentKey.startsWith('App.');
+ var name = isApp ? dependentKey.replace('App.', '') : dependentKey;
+ var context = isApp ? App : self;
+ sinon.stub(context, 'get', function (k) {
+ return k === name ? value : Em.get(context, k);
+ });
+ return this;
+ },
+
+ /**
+ * Stub <code>get</code>-method for <code>App</code> or <code>self</code> (depends on </code>hash</code>-keys)
+ * If some key is starts with 'App.' it will be used in the App-stub,
+ * otherwise it will be used in thw self-stub
+ *
+ * @param {Ember.Object} self
+ * @param {object} hash
+ * @returns {App.TestAliases}
+ * @private
+ */
+ _stubManyKeys: function (self, hash) {
+ var hashForApp = {}; // used in the App-stub
+ var hashForSelf = {}; // used in the self-stub
+ Object.keys(hash).forEach(function(key) {
+ var isApp = key.startsWith('App.');
+ var name = isApp ? key.replace('App.', '') : key;
+ if(isApp) {
+ hashForApp[name] = hash[key];
+ }
+ else {
+ hashForSelf[name] = hash[key];
+ }
+ });
+ sinon.stub(App, 'get', function (k) {
+ if (hashForApp.hasOwnProperty(k)) {
+ return hashForApp[k];
+ }
+ return Em.get(App, k);
+ });
+ sinon.stub(self, 'get', function (k) {
+ if (hashForSelf.hasOwnProperty(k)) {
+ return hashForSelf[k];
+ }
+ return Em.get(self, k);
+ });
+ return this;
+ }
+
+ }
+};
+
+require('test/aliases/computed/equal');
+require('test/aliases/computed/notEqual');
+require('test/aliases/computed/equalProperties');
+require('test/aliases/computed/notEqualProperties');
+require('test/aliases/computed/ifThenElse');
+require('test/aliases/computed/sumProperties');
+require('test/aliases/computed/countBasedMessage');
+require('test/aliases/computed/firstNotBlank');
+require('test/aliases/computed/percents');
+require('test/aliases/computed/existsIn');
+require('test/aliases/computed/notExistsIn');
+require('test/aliases/computed/alias');
+require('test/aliases/computed/gte');
+require('test/aliases/computed/gt');
+require('test/aliases/computed/gteProperties');
+require('test/aliases/computed/gtProperties');
+require('test/aliases/computed/lte');
+require('test/aliases/computed/lt');
+require('test/aliases/computed/lteProperties');
+require('test/aliases/computed/ltProperties');
+require('test/aliases/computed/someBy');
+require('test/aliases/computed/everyBy');
+require('test/aliases/computed/mapBy');
+require('test/aliases/computed/filterBy');
+require('test/aliases/computed/findBy');
+require('test/aliases/computed/sumBy');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/models/alerts/alert_group_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/alerts/alert_group_test.js b/ambari-web/test/models/alerts/alert_group_test.js
new file mode 100644
index 0000000..036a32d
--- /dev/null
+++ b/ambari-web/test/models/alerts/alert_group_test.js
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+function getModel() {
+ return App.AlertGroup.createRecord();
+}
+
+describe('App.AlertGroup', function() {
+
+ App.TestAliases.testAsComputedAlias(getModel(), 'isAddDefinitionsDisabled', 'default', 'boolean');
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/models/configs/theme/tab_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/theme/tab_test.js b/ambari-web/test/models/configs/theme/tab_test.js
new file mode 100644
index 0000000..813d997
--- /dev/null
+++ b/ambari-web/test/models/configs/theme/tab_test.js
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var model;
+
+function getModel() {
+ return App.Tab.createRecord();
+}
+
+describe('App.Tab', function () {
+
+ beforeEach(function () {
+ model = getModel();
+ });
+
+ App.TestAliases.testAsComputedSumBy(getModel(), 'errorsCount', 'sections', 'errorsCount');
+
+ App.TestAliases.testAsComputedIfThenElse(getModel(), 'tooltipMsg', 'isHiddenByFilter', Em.I18n.t('services.service.config.nothing.to.display') , '');
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/models/stack_version/repository_version_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/stack_version/repository_version_test.js b/ambari-web/test/models/stack_version/repository_version_test.js
new file mode 100644
index 0000000..9122d87
--- /dev/null
+++ b/ambari-web/test/models/stack_version/repository_version_test.js
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var model;
+
+function getModel() {
+ return App.RepositoryVersion.createRecord();
+}
+
+describe('App.RepositoryVersion', function () {
+
+ beforeEach(function () {
+ model = getModel();
+ });
+
+ App.TestAliases.testAsComputedFirstNotBlank(getModel(), 'status', ['stackVersion.state', 'defaultStatus']);
+
+ App.TestAliases.testAsComputedFirstNotBlank(getModel(), 'notInstalledHosts', ['stackVersion.notInstalledHosts', 'App.allHostNames']);
+
+ App.TestAliases.testAsComputedIfThenElse(getModel(), 'noInitHostsTooltip', 'noInitHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip'));
+
+ App.TestAliases.testAsComputedIfThenElse(getModel(), 'noCurrentHostsTooltip', 'noCurrentHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip'));
+
+ App.TestAliases.testAsComputedIfThenElse(getModel(), 'noInstalledHostsTooltip', 'noInstalledHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip'));
+
+});
[4/5] ambari git commit: AMBARI-14296. Add common tests for
Em.computed macros (onechiporenko)
Posted by on...@apache.org.
AMBARI-14296. Add common tests for Em.computed macros (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/240a27a5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/240a27a5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/240a27a5
Branch: refs/heads/trunk
Commit: 240a27a506419691a6556be67d193da1a04ffeea
Parents: df4bbdd
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Dec 9 17:49:11 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Dec 10 15:45:37 2015 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 4 +
ambari-web/app/utils/ember_computed.js | 22 +--
.../notification_configs_view.js | 4 +-
ambari-web/test/aliases/computed/alias.js | 67 ++++++++
.../test/aliases/computed/countBasedMessage.js | 65 +++++++
ambari-web/test/aliases/computed/equal.js | 56 ++++++
.../test/aliases/computed/equalProperties.js | 63 +++++++
ambari-web/test/aliases/computed/everyBy.js | 85 ++++++++++
ambari-web/test/aliases/computed/existsIn.js | 53 ++++++
ambari-web/test/aliases/computed/filterBy.js | 71 ++++++++
ambari-web/test/aliases/computed/findBy.js | 69 ++++++++
.../test/aliases/computed/firstNotBlank.js | 60 +++++++
ambari-web/test/aliases/computed/gt.js | 63 +++++++
.../test/aliases/computed/gtProperties.js | 72 ++++++++
ambari-web/test/aliases/computed/gte.js | 63 +++++++
.../test/aliases/computed/gteProperties.js | 72 ++++++++
ambari-web/test/aliases/computed/ifThenElse.js | 57 +++++++
ambari-web/test/aliases/computed/lt.js | 63 +++++++
.../test/aliases/computed/ltProperties.js | 72 ++++++++
ambari-web/test/aliases/computed/lte.js | 63 +++++++
.../test/aliases/computed/lteProperties.js | 72 ++++++++
ambari-web/test/aliases/computed/mapBy.js | 67 ++++++++
ambari-web/test/aliases/computed/notEqual.js | 56 ++++++
.../test/aliases/computed/notEqualProperties.js | 63 +++++++
ambari-web/test/aliases/computed/notExistsIn.js | 53 ++++++
ambari-web/test/aliases/computed/percents.js | 55 ++++++
ambari-web/test/aliases/computed/someBy.js | 90 ++++++++++
ambari-web/test/aliases/computed/sumBy.js | 67 ++++++++
.../test/aliases/computed/sumProperties.js | 67 ++++++++
ambari-web/test/init_computed_aliases.js | 169 +++++++++++++++++++
.../test/models/alerts/alert_group_test.js | 29 ++++
.../test/models/configs/theme/tab_test.js | 36 ++++
.../stack_version/repository_version_test.js | 42 +++++
33 files changed, 1997 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/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 99c7b76..3df5f1c 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -34,6 +34,7 @@ require('utils/ajax/ajax_queue');
var files = [
'test/init_test',
+ 'test/init_computed_aliases',
'test/init_model_test',
'test/app_test',
'test/data/HDP2/site_properties_test',
@@ -303,6 +304,7 @@ var files = [
'test/models/service/yarn_test',
'test/models/alerts/alert_config_test',
'test/models/alerts/alert_definition_test',
+ 'test/models/alerts/alert_group_test',
'test/models/alerts/alert_instance_test',
'test/models/authentication_test',
'test/models/cluster_states_test',
@@ -324,6 +326,8 @@ var files = [
'test/models/configs/objects/service_config_test',
'test/models/configs/objects/service_config_category_test',
'test/models/configs/objects/service_config_property_test',
+ 'test/models/configs/theme/tab_test',
+ 'test/models/stack_version/repository_version_test',
'test/routes/views_test',
//contains test with fake timers that affect Date
'test/utils/lazy_loading_test'
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/app/utils/ember_computed.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_computed.js b/ambari-web/app/utils/ember_computed.js
index a75fc50..b555a93 100644
--- a/ambari-web/app/utils/ember_computed.js
+++ b/ambari-web/app/utils/ember_computed.js
@@ -41,7 +41,7 @@ function getProperties(self, propertyNames) {
propertyName = shouldBeInverted ? propertyName.substr(1) : propertyName;
var isApp = propertyName.startsWith('App.');
var name = isApp ? propertyName.replace('App.', '') : propertyName;
- var value = isApp ? App.get(name) : get(self, name);
+ var value = isApp ? App.get(name) : self.get(name);
value = shouldBeInverted ? !value : value;
ret[propertyName] = value;
}
@@ -59,7 +59,7 @@ function getProperties(self, propertyNames) {
function smartGet(self, propertyName) {
var isApp = propertyName.startsWith('App.');
var name = isApp ? propertyName.replace('App.', '') : propertyName;
- return isApp ? App.get(name) : get(self, name);
+ return isApp ? App.get(name) : self.get(name);
}
/**
@@ -67,7 +67,7 @@ function smartGet(self, propertyName) {
* If <code>propertyName</code> starts with 'App.', <code>App</code> is used as context, <code>self</code> used otherwise
*
* @param {object} self current context
- * @param {string[]} propertyNames neded properties
+ * @param {string[]} propertyNames needed properties
* @returns {array} list of needed values
*/
function getValues(self, propertyNames) {
@@ -643,7 +643,7 @@ computed.match = function (dependentKey, regexp) {
*/
computed.someBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- var collection = get(this, collectionKey);
+ var collection = smartGet(this, collectionKey);
if (!collection) {
return false;
}
@@ -671,7 +671,7 @@ computed.someBy = function (collectionKey, propertyName, neededValue) {
*/
computed.everyBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- var collection = get(this, collectionKey);
+ var collection = smartGet(this, collectionKey);
if (!collection) {
return false;
}
@@ -698,7 +698,7 @@ computed.everyBy = function (collectionKey, propertyName, neededValue) {
*/
computed.mapBy = function (collectionKey, propertyName) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- var collection = get(this, collectionKey);
+ var collection = smartGet(this, collectionKey);
if (!collection) {
return [];
}
@@ -726,7 +726,7 @@ computed.mapBy = function (collectionKey, propertyName) {
*/
computed.filterBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- var collection = get(this, collectionKey);
+ var collection = smartGet(this, collectionKey);
if (!collection) {
return [];
}
@@ -754,7 +754,7 @@ computed.filterBy = function (collectionKey, propertyName, neededValue) {
*/
computed.findBy = function (collectionKey, propertyName, neededValue) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- var collection = get(this, collectionKey);
+ var collection = smartGet(this, collectionKey);
if (!collection) {
return null;
}
@@ -805,7 +805,7 @@ computed.alias = function (dependentKey) {
*/
computed.existsIn = function (dependentKey, neededValues) {
return computed(dependentKey, function () {
- var value = get(this, dependentKey);
+ var value = smartGet(this, dependentKey);
return makeArray(neededValues).contains(value);
});
};
@@ -829,7 +829,7 @@ computed.existsIn = function (dependentKey, neededValues) {
*/
computed.notExistsIn = function (dependentKey, neededValues) {
return computed(dependentKey, function () {
- var value = get(this, dependentKey);
+ var value = smartGet(this, dependentKey);
return !makeArray(neededValues).contains(value);
});
};
@@ -913,7 +913,7 @@ computed.formatRole = function (dependentKey) {
*/
computed.sumBy = function (collectionKey, propertyName) {
return computed(collectionKey + '.@each.' + propertyName, function () {
- var collection = get(this, collectionKey);
+ var collection = smartGet(this, collectionKey);
if (Em.isEmpty(collection)) {
return 0;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js b/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
index 9e34bd3..2947a95 100644
--- a/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
+++ b/ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
@@ -88,7 +88,7 @@ App.NotificationsConfigsView = App.ServiceConfigsByCategoryView.extend({
useAuthConfigValue = this.get('useAuthConfig.value'),
useAuthConfigIsEditable = this.get('useAuthConfig.isEditable'),
self = this;
- this.get('categoryConfigs').forEach(function (config) {
+ this.getWithDefault('categoryConfigs', []).forEach(function (config) {
if (configsToUpdate.contains(config.get('name'))) {
var flag = useAuthConfigIsEditable ? useAuthConfigValue : false;
self.updateConfig(config, flag);
@@ -105,7 +105,7 @@ App.NotificationsConfigsView = App.ServiceConfigsByCategoryView.extend({
updateCategoryConfigs: function () {
var createNotification = this.get('createNotification'),
self = this;
- this.get('categoryConfigs').forEach(function (config) {
+ this.getWithDefault('categoryConfigs', []).forEach(function (config) {
var flag = (createNotification == 'yes');
self.updateConfig(config, flag);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/alias.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/alias.js b/ambari-web/test/aliases/computed/alias.js
new file mode 100644
index 0000000..9605d73
--- /dev/null
+++ b/ambari-web/test/aliases/computed/alias.js
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {string} [type]
+ */
+App.TestAliases.testAsComputedAlias = function (context, propertyName, dependentKey, type) {
+ var testsCases = [];
+ var typesMap = {
+ string: ['1234', '', 'abc', '{}'],
+ number: [1234, 0, -1234, 1.2, -1.2],
+ boolean: [true, false],
+ object: [{a: 12345}, {}],
+ array: [[1,2,3], [], [{}, {a: 1}]]
+ };
+
+ if (type) {
+ testsCases = typesMap[type] || [];
+ }
+ else {
+ // all
+ testsCases = [].concat.call([], Object.keys(typesMap).map(function (key) {return typesMap[key]}));
+ }
+
+ describe('#' + propertyName + ' as Em.computed.alias', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ testsCases.forEach(function (testedValue) {
+ it('should be equal to the ' + JSON.stringify(dependentKey) + ' (' + Em.typeOf(testedValue) + ')', function () {
+ helpers.smartStubGet(context, dependentKey, testedValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql(testedValue);
+ });
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/countBasedMessage.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/countBasedMessage.js b/ambari-web/test/aliases/computed/countBasedMessage.js
new file mode 100644
index 0000000..29d06fb
--- /dev/null
+++ b/ambari-web/test/aliases/computed/countBasedMessage.js
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {string} zeroMessage
+ * @param {string} oneMessage
+ * @param {string} manyMessage
+ */
+App.TestAliases.testAsComputedCountBasedMessage = function (context, propertyName, dependentKey, zeroMessage, oneMessage, manyMessage) {
+
+ describe('#' + propertyName + ' as Em.computed.countBasedMessage', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be equal to `zeroMessage` if ' + JSON.stringify(dependentKey) + ' is 0', function () {
+ helpers.smartStubGet(context, dependentKey, 0)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(zeroMessage);
+ });
+
+ it('should be equal to `oneMessage` if ' + JSON.stringify(dependentKey) + ' is 1', function () {
+ helpers.smartStubGet(context, dependentKey, 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(oneMessage);
+ });
+
+ it('should be equal to `manyMessage` if ' + JSON.stringify(dependentKey) + ' is 1+', function () {
+ helpers.smartStubGet(context, dependentKey, 2)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(manyMessage);
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/equal.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/equal.js b/ambari-web/test/aliases/computed/equal.js
new file mode 100644
index 0000000..00ec2d1
--- /dev/null
+++ b/ambari-web/test/aliases/computed/equal.js
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {*} neededValue
+ */
+App.TestAliases.testAsComputedEqual = function (context, propertyName, dependentKey, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.equal', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is equal to the ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is not equal to the ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, Math.random())
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/equalProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/equalProperties.js b/ambari-web/test/aliases/computed/equalProperties.js
new file mode 100644
index 0000000..f98cc1e
--- /dev/null
+++ b/ambari-web/test/aliases/computed/equalProperties.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ */
+App.TestAliases.testAsComputedEqualProperties = function (context, propertyName, dependentKey1, dependentKey2) {
+
+ describe('#' + propertyName + ' as Em.computed.equalProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is equal to ' + JSON.stringify(dependentKey2), function () {
+ var someValue = '1234567';
+ var hash = {};
+ hash[dependentKey1] = someValue;
+ hash[dependentKey2] = someValue;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey1) + ' is not equal to ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = '12345';
+ hash[dependentKey2] = '54321';
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/everyBy.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/everyBy.js b/ambari-web/test/aliases/computed/everyBy.js
new file mode 100644
index 0000000..95a0b86
--- /dev/null
+++ b/ambari-web/test/aliases/computed/everyBy.js
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} collectionName
+ * @param {string} keyName
+ * @param {*} neededValue
+ */
+App.TestAliases.testAsComputedEveryBy = function (context, propertyName, collectionName, keyName, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.everyBy', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([collectionName + '.@each.' + keyName]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(collectionName) + ' is empty', function () {
+ helpers.smartStubGet(context, collectionName, [])
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `false` if ' + JSON.stringify(collectionName) + ' does not exist', function () {
+ helpers.smartStubGet(context, collectionName, null)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if no one object in the ' + JSON.stringify(collectionName) + ' does not have ' + JSON.stringify(keyName) + ' with value equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.setEach(keyName, !neededValue); // something that not equal to the `neededValue`
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if at least one object in the ' + JSON.stringify(collectionName) + ' does not have ' + JSON.stringify(keyName) + ' with value equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.setEach(keyName, neededValue);
+ collection[1][keyName] = !neededValue;
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if all objects in the ' + JSON.stringify(collectionName) + ' have ' + JSON.stringify(keyName) + ' with value equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.setEach(keyName, neededValue);
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/existsIn.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/existsIn.js b/ambari-web/test/aliases/computed/existsIn.js
new file mode 100644
index 0000000..4c3cce2
--- /dev/null
+++ b/ambari-web/test/aliases/computed/existsIn.js
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {array} neededValues
+ */
+App.TestAliases.testAsComputedExistsIn = function (context, propertyName, dependentKey, neededValues) {
+
+ describe('#' + propertyName + ' as Em.computed.existsIn', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ neededValues.forEach(function (neededValue) {
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is equal to ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/filterBy.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/filterBy.js b/ambari-web/test/aliases/computed/filterBy.js
new file mode 100644
index 0000000..154c372
--- /dev/null
+++ b/ambari-web/test/aliases/computed/filterBy.js
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} collectionName
+ * @param {string} keyName
+ * @param {*} neededValue
+ */
+App.TestAliases.testAsComputedFilterBy = function (context, propertyName, collectionName, keyName, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.filterBy', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([collectionName + '.@each.' + keyName]);
+ });
+
+ it('should be `[]` if ' + JSON.stringify(collectionName) + ' is empty', function () {
+ helpers.smartStubGet(context, collectionName, [])
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql([]);
+ });
+
+ it('should be `[]` if ' + JSON.stringify(collectionName) + ' does not exist', function () {
+ helpers.smartStubGet(context, collectionName, null)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql([]);
+ });
+
+ it('should be an array objects from ' + JSON.stringify(collectionName) + ' with ' + JSON.stringify(keyName) + ' equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.forEach(function (item) {
+ Ember.setFullPath(item, keyName, neededValue);
+ });
+
+ collection.setEach(keyName, neededValue);
+ Em.set(collection[2], keyName, !neededValue);
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql(collection.slice(0, 2));
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/findBy.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/findBy.js b/ambari-web/test/aliases/computed/findBy.js
new file mode 100644
index 0000000..a4495c3
--- /dev/null
+++ b/ambari-web/test/aliases/computed/findBy.js
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} collectionName
+ * @param {string} keyName
+ * @param {*} neededValue
+ */
+App.TestAliases.testAsComputedFindBy = function (context, propertyName, collectionName, keyName, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.findBy', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([collectionName + '.@each.' + keyName]);
+ });
+
+ it('should be `undefined` if ' + JSON.stringify(collectionName) + ' is empty', function () {
+ helpers.smartStubGet(context, collectionName, [])
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.undefined;
+ });
+
+ it('should be `null` if ' + JSON.stringify(collectionName) + ' does not exist', function () {
+ helpers.smartStubGet(context, collectionName, null)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.null;
+ });
+
+ it('should be a first object from ' + JSON.stringify(collectionName) + ' with ' + JSON.stringify(keyName) + ' equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{i: 0}, {i: 1}, {i: 2}];
+ collection.forEach(function (item) {
+ Ember.setFullPath(item, keyName, neededValue)
+ });
+ Em.set(collection[2], keyName, !neededValue);
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql(collection[0]);
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/firstNotBlank.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/firstNotBlank.js b/ambari-web/test/aliases/computed/firstNotBlank.js
new file mode 100644
index 0000000..7099fe5
--- /dev/null
+++ b/ambari-web/test/aliases/computed/firstNotBlank.js
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+function prepareHash(dependentKeys, index) {
+ var hash = {};
+ dependentKeys.forEach(function (key, i) {
+ hash[key] = i < index ? null : '' + i;
+ });
+ return hash;
+}
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string[]} dependentKeys
+ */
+App.TestAliases.testAsComputedFirstNotBlank = function (context, propertyName, dependentKeys) {
+
+ describe('#' + propertyName + ' as Em.computed.firstNotBlank', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql(dependentKeys);
+ });
+
+ dependentKeys.forEach(function(dependentKey, index) {
+
+ it('should be equal to the ' + JSON.stringify(dependentKey), function () {
+ helpers.smartStubGet(context, prepareHash(dependentKeys, index))
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal('' + index);
+ });
+
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/gt.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/gt.js b/ambari-web/test/aliases/computed/gt.js
new file mode 100644
index 0000000..bad86ea
--- /dev/null
+++ b/ambari-web/test/aliases/computed/gt.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {number} neededValue
+ */
+App.TestAliases.testAsComputedGt = function (context, propertyName, dependentKey, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.gt', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is greater than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue + 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is equal to ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is lower than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue - 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/gtProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/gtProperties.js b/ambari-web/test/aliases/computed/gtProperties.js
new file mode 100644
index 0000000..f3f1def
--- /dev/null
+++ b/ambari-web/test/aliases/computed/gtProperties.js
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ */
+App.TestAliases.testAsComputedGtProperties = function (context, propertyName, dependentKey1, dependentKey2) {
+
+ describe('#' + propertyName + ' as Em.computed.gtProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is greater than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 6;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey1) + ' is equal to ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 5;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is lower than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 4;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/gte.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/gte.js b/ambari-web/test/aliases/computed/gte.js
new file mode 100644
index 0000000..f1bd6a6
--- /dev/null
+++ b/ambari-web/test/aliases/computed/gte.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {number} neededValue
+ */
+App.TestAliases.testAsComputedGte = function (context, propertyName, dependentKey, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.gte', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is greater than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue + 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is equal to ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is lower than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue - 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/gteProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/gteProperties.js b/ambari-web/test/aliases/computed/gteProperties.js
new file mode 100644
index 0000000..287e29c
--- /dev/null
+++ b/ambari-web/test/aliases/computed/gteProperties.js
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ */
+App.TestAliases.testAsComputedGteProperties = function (context, propertyName, dependentKey1, dependentKey2) {
+
+ describe('#' + propertyName + ' as Em.computed.gteProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is greater than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 6;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is equal to ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 5;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is lower than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 4;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/ifThenElse.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/ifThenElse.js b/ambari-web/test/aliases/computed/ifThenElse.js
new file mode 100644
index 0000000..71d88cf
--- /dev/null
+++ b/ambari-web/test/aliases/computed/ifThenElse.js
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {*} trueValue
+ * @param {*} falseValue
+ */
+App.TestAliases.testAsComputedIfThenElse = function (context, propertyName, dependentKey, trueValue, falseValue) {
+
+ describe('#' + propertyName + ' as Em.computed.ifThenElse', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `trueValue` if ' + JSON.stringify(dependentKey) + ' is `true`', function () {
+ helpers.smartStubGet(context, dependentKey, true)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(trueValue);
+ });
+
+ it('should be `falseValue` if ' + JSON.stringify(dependentKey) + ' is `false`', function () {
+ helpers.smartStubGet(context, dependentKey, false)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(falseValue);
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/lt.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/lt.js b/ambari-web/test/aliases/computed/lt.js
new file mode 100644
index 0000000..6af3e0f
--- /dev/null
+++ b/ambari-web/test/aliases/computed/lt.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {number} neededValue
+ */
+App.TestAliases.testAsComputedLt = function (context, propertyName, dependentKey, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.lt', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is greater than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue + 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is equal to ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is lower than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue - 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/ltProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/ltProperties.js b/ambari-web/test/aliases/computed/ltProperties.js
new file mode 100644
index 0000000..2a5b378
--- /dev/null
+++ b/ambari-web/test/aliases/computed/ltProperties.js
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ */
+App.TestAliases.testAsComputedLtProperties = function (context, propertyName, dependentKey1, dependentKey2) {
+
+ describe('#' + propertyName + ' as Em.computed.lteProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey1) + ' is greater than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 6;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey1) + ' is equal to ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 5;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is lower than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 4;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/lte.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/lte.js b/ambari-web/test/aliases/computed/lte.js
new file mode 100644
index 0000000..ccb45ee
--- /dev/null
+++ b/ambari-web/test/aliases/computed/lte.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {number} neededValue
+ */
+App.TestAliases.testAsComputedLte = function (context, propertyName, dependentKey, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.lte', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is greater than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue + 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is equal to ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is lower than ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue - 1)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/lteProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/lteProperties.js b/ambari-web/test/aliases/computed/lteProperties.js
new file mode 100644
index 0000000..dd3ba61
--- /dev/null
+++ b/ambari-web/test/aliases/computed/lteProperties.js
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ */
+App.TestAliases.testAsComputedLteProperties = function (context, propertyName, dependentKey1, dependentKey2) {
+
+ describe('#' + propertyName + ' as Em.computed.lteProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey1) + ' is greater than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 6;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is equal to ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 5;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is lower than ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = 4;
+ hash[dependentKey2] = 5;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/mapBy.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/mapBy.js b/ambari-web/test/aliases/computed/mapBy.js
new file mode 100644
index 0000000..bbdcaf7
--- /dev/null
+++ b/ambari-web/test/aliases/computed/mapBy.js
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} collectionName
+ * @param {string} keyName
+ */
+App.TestAliases.testAsComputedMapBy = function (context, propertyName, collectionName, keyName) {
+
+ describe('#' + propertyName + ' as Em.computed.mapBy', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([collectionName + '.@each.' + keyName]);
+ });
+
+ it('should be `[]` if ' + JSON.stringify(collectionName) + ' is empty', function () {
+ helpers.smartStubGet(context, collectionName, [])
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql([]);
+ });
+
+ it('should be `[]` if ' + JSON.stringify(collectionName) + ' does not exist', function () {
+ helpers.smartStubGet(context, collectionName, null)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql([]);
+ });
+
+ it('should be an array with values of each ' + JSON.stringify(keyName) + ' in the ' + JSON.stringify(collectionName), function () {
+ var collection = [{}, {}, {}];
+ collection.forEach(function (item, index) {
+ Ember.setFullPath(item, keyName, index);
+ });
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.eql([0, 1, 2]);
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/notEqual.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/notEqual.js b/ambari-web/test/aliases/computed/notEqual.js
new file mode 100644
index 0000000..7d6199d
--- /dev/null
+++ b/ambari-web/test/aliases/computed/notEqual.js
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {*} neededValue
+ */
+App.TestAliases.testAsComputedNotEqual = function (context, propertyName, dependentKey, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.notEqual', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is equal to the ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey) + ' is not equal to the ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, Math.random())
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/notEqualProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/notEqualProperties.js b/ambari-web/test/aliases/computed/notEqualProperties.js
new file mode 100644
index 0000000..020127a
--- /dev/null
+++ b/ambari-web/test/aliases/computed/notEqualProperties.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ */
+App.TestAliases.testAsComputedNotEqualProperties = function (context, propertyName, dependentKey1, dependentKey2) {
+
+ describe('#' + propertyName + ' as Em.computed.notEqualProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(dependentKey1) + ' is equal to the ' + JSON.stringify(dependentKey2), function () {
+ var someValue = '1234567';
+ var hash = {};
+ hash[dependentKey1] = someValue;
+ hash[dependentKey2] = someValue;
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if ' + JSON.stringify(dependentKey1) + ' is not equal to the ' + JSON.stringify(dependentKey2), function () {
+ var hash = {};
+ hash[dependentKey1] = '12345';
+ hash[dependentKey2] = '54321';
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/notExistsIn.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/notExistsIn.js b/ambari-web/test/aliases/computed/notExistsIn.js
new file mode 100644
index 0000000..8241e66
--- /dev/null
+++ b/ambari-web/test/aliases/computed/notExistsIn.js
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey
+ * @param {array} neededValues
+ */
+App.TestAliases.testAsComputedNotExistsIn = function (context, propertyName, dependentKey, neededValues) {
+
+ describe('#' + propertyName + ' as Em.computed.notExistsIn', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]);
+ });
+
+ neededValues.forEach(function (neededValue) {
+
+ it('should be `false` if ' + JSON.stringify(dependentKey) + ' is equal to ' + JSON.stringify(neededValue), function () {
+ helpers.smartStubGet(context, dependentKey, neededValue)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/percents.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/percents.js b/ambari-web/test/aliases/computed/percents.js
new file mode 100644
index 0000000..4811a68
--- /dev/null
+++ b/ambari-web/test/aliases/computed/percents.js
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} dependentKey1
+ * @param {string} dependentKey2
+ * @param {number} [accuracy=0]
+ */
+App.TestAliases.testAsComputedPercents = function (context, propertyName, dependentKey1, dependentKey2, accuracy) {
+
+ describe('#' + propertyName + ' as Em.computed.percents', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey1, dependentKey2]);
+ });
+
+ it('should be calculated with ' + JSON.stringify(dependentKey1) + ' and ' + JSON.stringify(dependentKey2), function() {
+ var hash = {};
+ hash[dependentKey1] = 10;
+ hash[dependentKey2] = 20;
+ var result = 10 / 20 * 100;
+ result = accuracy ? parseFloat(result.toFixed(accuracy)) : Math.round(result);
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(result);
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/someBy.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/someBy.js b/ambari-web/test/aliases/computed/someBy.js
new file mode 100644
index 0000000..5332923
--- /dev/null
+++ b/ambari-web/test/aliases/computed/someBy.js
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} collectionName
+ * @param {string} keyName
+ * @param {*} neededValue
+ */
+App.TestAliases.testAsComputedSomeBy = function (context, propertyName, collectionName, keyName, neededValue) {
+
+ describe('#' + propertyName + ' as Em.computed.someBy', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([collectionName + '.@each.' + keyName]);
+ });
+
+ it('should be `false` if ' + JSON.stringify(collectionName) + ' is empty', function () {
+ helpers.smartStubGet(context, collectionName, [])
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if ' + JSON.stringify(collectionName) + ' does not exist', function () {
+ helpers.smartStubGet(context, collectionName, null)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `false` if no one object in the ' + JSON.stringify(collectionName) + ' does not have ' + JSON.stringify(keyName) + ' with value equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.setEach(keyName, !neededValue); // something that not equal to the `neededValue`
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.false;
+ });
+
+ it('should be `true` if at least one object in the ' + JSON.stringify(collectionName) + ' has ' + JSON.stringify(keyName) + ' with value equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.setEach(keyName, !neededValue);
+ collection.forEach(function (item) {
+ Em.setFullPath(item, keyName, !neededValue);
+ });
+ Em.set(collection[1], keyName, neededValue);
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ it('should be `true` if all objects in the ' + JSON.stringify(collectionName) + ' have ' + JSON.stringify(keyName) + ' with value equal to the ' + JSON.stringify(neededValue), function () {
+ var collection = [{}, {}, {}];
+ collection.forEach(function (item) {
+ Em.setFullPath(item, keyName, neededValue);
+ });
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.be.true;
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/sumBy.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/sumBy.js b/ambari-web/test/aliases/computed/sumBy.js
new file mode 100644
index 0000000..871dd86
--- /dev/null
+++ b/ambari-web/test/aliases/computed/sumBy.js
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string} collectionName
+ * @param {string} keyName
+ */
+App.TestAliases.testAsComputedSumBy = function (context, propertyName, collectionName, keyName) {
+
+ describe('#' + propertyName + ' as Em.computed.sumBy', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([collectionName + '.@each.' + keyName]);
+ });
+
+ it('should be `0` if ' + JSON.stringify(collectionName) + ' is empty', function () {
+ helpers.smartStubGet(context, collectionName, [])
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(0);
+ });
+
+ it('should be `0` if ' + JSON.stringify(collectionName) + ' does not exist', function () {
+ helpers.smartStubGet(context, collectionName, null)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(0);
+ });
+
+ it('should be a sum of the values of each ' + JSON.stringify(keyName) + ' in the ' + JSON.stringify(collectionName), function () {
+ var collection = [{}, {}, {}];
+ collection.forEach(function (item, index) {
+ Ember.setFullPath(item, keyName, index);
+ });
+ helpers.smartStubGet(context, collectionName, collection)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(3); // 0 + 1 + 2
+ });
+
+ });
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/240a27a5/ambari-web/test/aliases/computed/sumProperties.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/aliases/computed/sumProperties.js b/ambari-web/test/aliases/computed/sumProperties.js
new file mode 100644
index 0000000..898def4
--- /dev/null
+++ b/ambari-web/test/aliases/computed/sumProperties.js
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var helpers = App.TestAliases.helpers;
+
+/**
+ *
+ * @param {Em.Object} context
+ * @param {string} propertyName
+ * @param {string[]} dependentKeys
+ */
+App.TestAliases.testAsComputedSumProperties = function (context, propertyName, dependentKeys) {
+
+ describe('#' + propertyName + ' as Em.computed.sumProperties', function () {
+
+ afterEach(function () {
+ helpers.smartRestoreGet(context);
+ });
+
+ it('has valid dependent keys', function () {
+ expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql(dependentKeys);
+ });
+
+ it('should calculate sum of the ' + JSON.stringify(dependentKeys), function () {
+ var hash = {};
+ var result = 0;
+ dependentKeys.forEach(function (k, i) {
+ hash[k] = i;
+ result += i;
+ });
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(result);
+ });
+
+ it('should calculate sum of the ' + JSON.stringify(dependentKeys) + ' (2)', function () {
+ var hash = {};
+ var result = 0;
+ dependentKeys.forEach(function (k, i) {
+ hash[k] = i * 2;
+ result += i * 2;
+ });
+ helpers.smartStubGet(context, hash)
+ .propertyDidChange(context, propertyName);
+ var value = helpers.smartGet(context, propertyName);
+ expect(value).to.equal(result);
+ });
+
+ });
+
+};
\ No newline at end of file