Browse Source

AMBARI-14296. Add common tests for Em.computed macros (onechiporenko)

Oleg Nechiporenko 9 years ago
parent
commit
240a27a506
33 changed files with 1997 additions and 13 deletions
  1. 4 0
      ambari-web/app/assets/test/tests.js
  2. 11 11
      ambari-web/app/utils/ember_computed.js
  3. 2 2
      ambari-web/app/views/common/configs/custom_category_views/notification_configs_view.js
  4. 67 0
      ambari-web/test/aliases/computed/alias.js
  5. 65 0
      ambari-web/test/aliases/computed/countBasedMessage.js
  6. 56 0
      ambari-web/test/aliases/computed/equal.js
  7. 63 0
      ambari-web/test/aliases/computed/equalProperties.js
  8. 85 0
      ambari-web/test/aliases/computed/everyBy.js
  9. 53 0
      ambari-web/test/aliases/computed/existsIn.js
  10. 71 0
      ambari-web/test/aliases/computed/filterBy.js
  11. 69 0
      ambari-web/test/aliases/computed/findBy.js
  12. 60 0
      ambari-web/test/aliases/computed/firstNotBlank.js
  13. 63 0
      ambari-web/test/aliases/computed/gt.js
  14. 72 0
      ambari-web/test/aliases/computed/gtProperties.js
  15. 63 0
      ambari-web/test/aliases/computed/gte.js
  16. 72 0
      ambari-web/test/aliases/computed/gteProperties.js
  17. 57 0
      ambari-web/test/aliases/computed/ifThenElse.js
  18. 63 0
      ambari-web/test/aliases/computed/lt.js
  19. 72 0
      ambari-web/test/aliases/computed/ltProperties.js
  20. 63 0
      ambari-web/test/aliases/computed/lte.js
  21. 72 0
      ambari-web/test/aliases/computed/lteProperties.js
  22. 67 0
      ambari-web/test/aliases/computed/mapBy.js
  23. 56 0
      ambari-web/test/aliases/computed/notEqual.js
  24. 63 0
      ambari-web/test/aliases/computed/notEqualProperties.js
  25. 53 0
      ambari-web/test/aliases/computed/notExistsIn.js
  26. 55 0
      ambari-web/test/aliases/computed/percents.js
  27. 90 0
      ambari-web/test/aliases/computed/someBy.js
  28. 67 0
      ambari-web/test/aliases/computed/sumBy.js
  29. 67 0
      ambari-web/test/aliases/computed/sumProperties.js
  30. 169 0
      ambari-web/test/init_computed_aliases.js
  31. 29 0
      ambari-web/test/models/alerts/alert_group_test.js
  32. 36 0
      ambari-web/test/models/configs/theme/tab_test.js
  33. 42 0
      ambari-web/test/models/stack_version/repository_version_test.js

+ 4 - 0
ambari-web/app/assets/test/tests.js

@@ -34,6 +34,7 @@ require('utils/ajax/ajax_queue');
 
 
 var files = [
 var files = [
   'test/init_test',
   'test/init_test',
+  'test/init_computed_aliases',
   'test/init_model_test',
   'test/init_model_test',
   'test/app_test',
   'test/app_test',
   'test/data/HDP2/site_properties_test',
   'test/data/HDP2/site_properties_test',
@@ -303,6 +304,7 @@ var files = [
   'test/models/service/yarn_test',
   'test/models/service/yarn_test',
   'test/models/alerts/alert_config_test',
   'test/models/alerts/alert_config_test',
   'test/models/alerts/alert_definition_test',
   'test/models/alerts/alert_definition_test',
+  'test/models/alerts/alert_group_test',
   'test/models/alerts/alert_instance_test',
   'test/models/alerts/alert_instance_test',
   'test/models/authentication_test',
   'test/models/authentication_test',
   'test/models/cluster_states_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_test',
   'test/models/configs/objects/service_config_category_test',
   'test/models/configs/objects/service_config_category_test',
   'test/models/configs/objects/service_config_property_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',
   'test/routes/views_test',
   //contains test with fake timers that affect Date
   //contains test with fake timers that affect Date
   'test/utils/lazy_loading_test'
   'test/utils/lazy_loading_test'

+ 11 - 11
ambari-web/app/utils/ember_computed.js

@@ -41,7 +41,7 @@ function getProperties(self, propertyNames) {
     propertyName = shouldBeInverted ? propertyName.substr(1) : propertyName;
     propertyName = shouldBeInverted ? propertyName.substr(1) : propertyName;
     var isApp = propertyName.startsWith('App.');
     var isApp = propertyName.startsWith('App.');
     var name = isApp ? propertyName.replace('App.', '') : propertyName;
     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;
     value = shouldBeInverted ? !value : value;
     ret[propertyName] = value;
     ret[propertyName] = value;
   }
   }
@@ -59,7 +59,7 @@ function getProperties(self, propertyNames) {
 function smartGet(self, propertyName) {
 function smartGet(self, propertyName) {
   var isApp = propertyName.startsWith('App.');
   var isApp = propertyName.startsWith('App.');
   var name = isApp ? propertyName.replace('App.', '') : propertyName;
   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
  * 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 {object} self current context
- * @param {string[]} propertyNames neded properties
+ * @param {string[]} propertyNames needed properties
  * @returns {array} list of needed values
  * @returns {array} list of needed values
  */
  */
 function getValues(self, propertyNames) {
 function getValues(self, propertyNames) {
@@ -643,7 +643,7 @@ computed.match = function (dependentKey, regexp) {
  */
  */
 computed.someBy = function (collectionKey, propertyName, neededValue) {
 computed.someBy = function (collectionKey, propertyName, neededValue) {
   return computed(collectionKey + '.@each.' + propertyName, function () {
   return computed(collectionKey + '.@each.' + propertyName, function () {
-    var collection = get(this, collectionKey);
+    var collection = smartGet(this, collectionKey);
     if (!collection) {
     if (!collection) {
       return false;
       return false;
     }
     }
@@ -671,7 +671,7 @@ computed.someBy = function (collectionKey, propertyName, neededValue) {
  */
  */
 computed.everyBy = function (collectionKey, propertyName, neededValue) {
 computed.everyBy = function (collectionKey, propertyName, neededValue) {
   return computed(collectionKey + '.@each.' + propertyName, function () {
   return computed(collectionKey + '.@each.' + propertyName, function () {
-    var collection = get(this, collectionKey);
+    var collection = smartGet(this, collectionKey);
     if (!collection) {
     if (!collection) {
       return false;
       return false;
     }
     }
@@ -698,7 +698,7 @@ computed.everyBy = function (collectionKey, propertyName, neededValue) {
  */
  */
 computed.mapBy = function (collectionKey, propertyName) {
 computed.mapBy = function (collectionKey, propertyName) {
   return computed(collectionKey + '.@each.' + propertyName, function () {
   return computed(collectionKey + '.@each.' + propertyName, function () {
-    var collection = get(this, collectionKey);
+    var collection = smartGet(this, collectionKey);
     if (!collection) {
     if (!collection) {
       return [];
       return [];
     }
     }
@@ -726,7 +726,7 @@ computed.mapBy = function (collectionKey, propertyName) {
  */
  */
 computed.filterBy = function (collectionKey, propertyName, neededValue) {
 computed.filterBy = function (collectionKey, propertyName, neededValue) {
   return computed(collectionKey + '.@each.' + propertyName, function () {
   return computed(collectionKey + '.@each.' + propertyName, function () {
-    var collection = get(this, collectionKey);
+    var collection = smartGet(this, collectionKey);
     if (!collection) {
     if (!collection) {
       return [];
       return [];
     }
     }
@@ -754,7 +754,7 @@ computed.filterBy = function (collectionKey, propertyName, neededValue) {
  */
  */
 computed.findBy = function (collectionKey, propertyName, neededValue) {
 computed.findBy = function (collectionKey, propertyName, neededValue) {
   return computed(collectionKey + '.@each.' + propertyName, function () {
   return computed(collectionKey + '.@each.' + propertyName, function () {
-    var collection = get(this, collectionKey);
+    var collection = smartGet(this, collectionKey);
     if (!collection) {
     if (!collection) {
       return null;
       return null;
     }
     }
@@ -805,7 +805,7 @@ computed.alias = function (dependentKey) {
  */
  */
 computed.existsIn = function (dependentKey, neededValues) {
 computed.existsIn = function (dependentKey, neededValues) {
   return computed(dependentKey, function () {
   return computed(dependentKey, function () {
-    var value = get(this, dependentKey);
+    var value = smartGet(this, dependentKey);
     return makeArray(neededValues).contains(value);
     return makeArray(neededValues).contains(value);
   });
   });
 };
 };
@@ -829,7 +829,7 @@ computed.existsIn = function (dependentKey, neededValues) {
  */
  */
 computed.notExistsIn = function (dependentKey, neededValues) {
 computed.notExistsIn = function (dependentKey, neededValues) {
   return computed(dependentKey, function () {
   return computed(dependentKey, function () {
-    var value = get(this, dependentKey);
+    var value = smartGet(this, dependentKey);
     return !makeArray(neededValues).contains(value);
     return !makeArray(neededValues).contains(value);
   });
   });
 };
 };
@@ -913,7 +913,7 @@ computed.formatRole = function (dependentKey) {
  */
  */
 computed.sumBy = function (collectionKey, propertyName) {
 computed.sumBy = function (collectionKey, propertyName) {
   return computed(collectionKey + '.@each.' + propertyName, function () {
   return computed(collectionKey + '.@each.' + propertyName, function () {
-    var collection = get(this, collectionKey);
+    var collection = smartGet(this, collectionKey);
     if (Em.isEmpty(collection)) {
     if (Em.isEmpty(collection)) {
       return 0;
       return 0;
     }
     }

+ 2 - 2
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'),
       useAuthConfigValue = this.get('useAuthConfig.value'),
       useAuthConfigIsEditable = this.get('useAuthConfig.isEditable'),
       useAuthConfigIsEditable = this.get('useAuthConfig.isEditable'),
       self = this;
       self = this;
-    this.get('categoryConfigs').forEach(function (config) {
+    this.getWithDefault('categoryConfigs', []).forEach(function (config) {
       if (configsToUpdate.contains(config.get('name'))) {
       if (configsToUpdate.contains(config.get('name'))) {
         var flag = useAuthConfigIsEditable ? useAuthConfigValue : false;
         var flag = useAuthConfigIsEditable ? useAuthConfigValue : false;
         self.updateConfig(config, flag);
         self.updateConfig(config, flag);
@@ -105,7 +105,7 @@ App.NotificationsConfigsView = App.ServiceConfigsByCategoryView.extend({
   updateCategoryConfigs: function () {
   updateCategoryConfigs: function () {
     var createNotification = this.get('createNotification'),
     var createNotification = this.get('createNotification'),
       self = this;
       self = this;
-    this.get('categoryConfigs').forEach(function (config) {
+    this.getWithDefault('categoryConfigs', []).forEach(function (config) {
       var flag = (createNotification == 'yes');
       var flag = (createNotification == 'yes');
       self.updateConfig(config, flag);
       self.updateConfig(config, flag);
     });
     });

+ 67 - 0
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);
+      });
+    });
+
+  });
+
+};

+ 65 - 0
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);
+    });
+
+  });
+
+};

+ 56 - 0
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;
+    });
+
+  });
+
+};

+ 63 - 0
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;
+    });
+
+  });
+
+};

+ 85 - 0
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;
+    });
+
+  });
+
+};

+ 53 - 0
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;
+      });
+
+    });
+
+  });
+
+};

+ 71 - 0
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));
+    });
+
+  });
+
+};

+ 69 - 0
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]);
+    });
+
+  });
+
+};

+ 60 - 0
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);
+      });
+
+    });
+
+  });
+
+};

+ 63 - 0
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;
+    });
+
+  });
+
+};

+ 72 - 0
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;
+    });
+
+  });
+
+};

+ 63 - 0
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;
+    });
+
+  });
+
+};

+ 72 - 0
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;
+    });
+
+  });
+
+};

+ 57 - 0
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);
+    });
+
+  });
+
+};

+ 63 - 0
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;
+    });
+
+  });
+
+};

+ 72 - 0
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;
+    });
+
+  });
+
+};

+ 63 - 0
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;
+    });
+
+  });
+
+};

+ 72 - 0
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;
+    });
+
+  });
+
+};

+ 67 - 0
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]);
+    });
+
+  });
+
+};

+ 56 - 0
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;
+    });
+
+  });
+
+};

+ 63 - 0
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;
+    });
+
+  });
+
+};

+ 53 - 0
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;
+      });
+
+    });
+
+  });
+
+};

+ 55 - 0
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);
+    });
+
+  });
+
+};

+ 90 - 0
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;
+    });
+
+  });
+
+};

+ 67 - 0
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
+    });
+
+  });
+
+};

+ 67 - 0
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);
+    });
+
+  });
+
+};

+ 169 - 0
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');

+ 29 - 0
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');
+
+});

+ 36 - 0
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') , '');
+
+});

+ 42 - 0
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'));
+
+});