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:15 UTC
[4/5] ambari git commit: AMBARI-14296. Add common tests for
Em.computed macros (onechiporenko)
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