123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- /**
- * 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('controllers/main/admin/misc_controller');
- describe('App.MainAdminMiscController', function () {
- var controller = App.MainAdminMiscController.create();
- describe('#setContentProperty()', function () {
- var testCases = [
- {
- title: 'key is null',
- content: {
- key: null,
- configName: 'cc',
- miscConfigs: []
- },
- result: {
- output: false,
- configValue: 'test'
- }
- },
- {
- title: 'configName is null',
- content: {
- key: 'key',
- configName: null,
- miscConfigs: []
- },
- result: {
- output: false,
- configValue: 'test'
- }
- },
- {
- title: 'misc configs array doesn\'t contain such a config',
- content: {
- key: 'key',
- configName: 'config1',
- miscConfigs: []
- },
- result: {
- output: false,
- configValue: 'test'
- }
- },
- {
- title: 'content doesn\'t contain such a key',
- content: {
- key: 'key',
- configName: 'config1',
- miscConfigs: [
- Em.Object.create({
- name: 'test_key'
- })
- ]
- },
- result: {
- output: false,
- configValue: 'test'
- }
- },
- {
- title: 'content property match config',
- content: {
- key: 'testKey',
- configName: 'test_key',
- miscConfigs: [
- Em.Object.create({
- name: 'test_key',
- value: 'testValue'
- })
- ]
- },
- result: {
- output: true,
- configValue: 'testValue'
- }
- }
- ];
- controller.set('content', Em.Object.create({testKey: 'test'}));
- testCases.forEach(function (test) {
- it(test.title, function () {
- var content = controller.get('content');
- expect(controller.setContentProperty(test.content.key, test.content.configName, test.content.miscConfigs)).to.equal(test.result.output);
- expect(content.get('testKey')).to.equal(test.result.configValue);
- });
- });
- });
- describe('#sortByOrder()', function () {
- var testCases = [
- {
- title: 'sortOrder is null',
- content: {
- sortOrder: null,
- arrayToSort: [
- {
- name: 'one',
- displayName: 'one'
- }
- ]
- },
- result: ['one']
- },
- {
- title: 'sortOrder is empty',
- content: {
- sortOrder: [],
- arrayToSort: [
- {
- name: 'one',
- displayName: 'one'
- }
- ]
- },
- result: ['one']
- },
- {
- title: 'sortOrder items don\'t match items of array',
- content: {
- sortOrder: ['one'],
- arrayToSort: [
- {name: 'two'}
- ]
- },
- result: []
- },
- {
- title: 'sort items in reverse order',
- content: {
- sortOrder: ['two', 'one'],
- arrayToSort: [
- Em.Object.create({
- name: 'one',
- displayName: 'one'
- }),
- Em.Object.create({
- name: 'two',
- displayName: 'two'
- })
- ]
- },
- result: ['two', 'one']
- },
- {
- title: 'sort items in correct order',
- content: {
- sortOrder: ['one', 'two'],
- arrayToSort: [
- Em.Object.create({
- name: 'one',
- displayName: 'one'
- }),
- Em.Object.create({
- name: 'two',
- displayName: 'two'
- })
- ]
- },
- result: ['one', 'two']
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- expect(controller.sortByOrder(test.content.sortOrder, test.content.arrayToSort).mapProperty('displayName')).to.eql(test.result);
- });
- });
- });
- describe('#setProxyUserGroupLabel()', function () {
- it('proxyuser_group config is absent', function () {
- var misc_configs = [];
- controller.setProxyUserGroupLabel(misc_configs);
- expect(misc_configs.findProperty('name', 'proxyuser_group')).to.be.undefined;
- });
- it('if currentStackVersionNumber less than 2.1 then label should be omitting "FALCON" service', function () {
- var misc_configs = [Em.Object.create({
- name: 'proxyuser_group',
- displayName: 'test'
- })];
- App.set('currentStackVersion', "HDP-2.0");
- controller.setProxyUserGroupLabel(misc_configs);
- expect(misc_configs.findProperty('name', 'proxyuser_group').get('displayName')).to.equal('Proxy group for Hive, WebHCat and Oozie');
- });
- it('if currentStackVersionNumber equal 2.1 then label should stay the same', function () {
- var misc_configs = [Em.Object.create({
- name: 'proxyuser_group',
- displayName: 'test'
- })];
- App.set('currentStackVersion', "HDP-2.1");
- controller.setProxyUserGroupLabel(misc_configs);
- expect(misc_configs.findProperty('name', 'proxyuser_group').get('displayName')).to.equal('test');
- });
- it('if currentStackVersionNumber higher than 2.1 then label should stay the same', function () {
- var misc_configs = [Em.Object.create({
- name: 'proxyuser_group',
- displayName: 'test'
- })];
- App.set('currentStackVersion', "HDP-2.2");
- controller.setProxyUserGroupLabel(misc_configs);
- expect(misc_configs.findProperty('name', 'proxyuser_group').get('displayName')).to.equal('test');
- });
- })
- });
|