Updated Branches: refs/heads/trunk 31820900a -> b5d5576f6
AMBARI-2735. Sorting configurations tests. (Andrii Tkach via yusaku) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/b5d5576f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/b5d5576f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/b5d5576f Branch: refs/heads/trunk Commit: b5d5576f6c2ac91364a23b15dd4c0fec4b6e9508 Parents: 3182090 Author: Yusaku Sako <[email protected]> Authored: Mon Jul 29 13:30:30 2013 -0700 Committer: Yusaku Sako <[email protected]> Committed: Mon Jul 29 13:30:30 2013 -0700 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../common/configs/services_config_test.js | 106 +++++++++++++++++++ 2 files changed, 107 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b5d5576f/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 531ac68..16b466a 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -62,5 +62,6 @@ require('test/utils/config_test'); require('test/utils/string_utils_test'); require('test/views/common/chart/linear_time_test'); require('test/views/common/filter_view_test'); +require('test/views/common/configs/services_config_test'); require('test/models/host_test'); require('test/models/rack_test'); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b5d5576f/ambari-web/test/views/common/configs/services_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/services_config_test.js b/ambari-web/test/views/common/configs/services_config_test.js new file mode 100644 index 0000000..cf08b22 --- /dev/null +++ b/ambari-web/test/views/common/configs/services_config_test.js @@ -0,0 +1,106 @@ +/** + * 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'); +require('views/common/chart/pie'); +require('views/common/configs/services_config'); + + +describe('App.ServiceConfigsByCategoryView', function () { + + var view = App.ServiceConfigsByCategoryView.create({ + serviceConfigs: [] + }); + + var result = [1, 2, 3, 4]; + + var testData = [ + { + title: 'four configs in correct order', + configs: [ + Em.Object.create({index: 1, resultId: 1}), + Em.Object.create({index: 2, resultId: 2}), + Em.Object.create({index: 3, resultId: 3}), + Em.Object.create({index: 4, resultId: 4}) + ] + }, + { + title: 'four configs in reverse order', + configs: [ + Em.Object.create({index: 4, resultId: 4}), + Em.Object.create({index: 3, resultId: 3}), + Em.Object.create({index: 2, resultId: 2}), + Em.Object.create({index: 1, resultId: 1}) + ] + }, + { + title: 'four configs in random order', + configs: [ + Em.Object.create({index: 3, resultId: 3}), + Em.Object.create({index: 4, resultId: 4}), + Em.Object.create({index: 1, resultId: 1}), + Em.Object.create({index: 2, resultId: 2}) + ] + }, + { + title: 'four configs with no index', + configs: [ + Em.Object.create({resultId: 1}), + Em.Object.create({resultId: 2}), + Em.Object.create({resultId: 3}), + Em.Object.create({resultId: 4}) + ] + }, + { + title: 'four configs but one with index', + configs: [ + Em.Object.create({resultId: 2}), + Em.Object.create({resultId: 3}), + Em.Object.create({resultId: 4}), + Em.Object.create({index: 1, resultId: 1}) + ] + }, + { + title: 'index is null or not number', + configs: [ + Em.Object.create({index: null, resultId: 3}), + Em.Object.create({index: 1, resultId: 1}), + Em.Object.create({index: 2, resultId: 2}), + Em.Object.create({index: 'a', resultId: 4}) + ] + }, + { + title: 'four configs when indexes skipped', + configs: [ + Em.Object.create({index: 88, resultId: 3}), + Em.Object.create({index: 67, resultId: 2}), + Em.Object.create({index: 111, resultId: 4}), + Em.Object.create({index: 3, resultId: 1}) + ] + } + ]; + + describe('#sortByIndex', function () { + testData.forEach(function(_test){ + it(_test.title, function () { + expect(view.sortByIndex(_test.configs).mapProperty('resultId')).to.deep.equal(result); + }) + }) + + }) +});
