123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- /**
- * 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/host/configs_service');
- describe('App.MainHostServiceConfigsController', function () {
- var controller = App.MainHostServiceConfigsController.create({
- host: Em.Object.create()
- });
- describe('#filterServiceConfigs()', function () {
- var testCases = [
- {
- title: 'configCategories is empty',
- content: {
- configCategories: [],
- hostComponents: []
- },
- result: []
- },
- {
- title: 'Category hostComponentNames is null',
- content: {
- configCategories: [
- Em.Object.create({hostComponentNames: null})
- ],
- hostComponents: []
- },
- result: [
- Em.Object.create({hostComponentNames: null})
- ]
- },
- {
- title: 'Components of host are empty',
- content: {
- configCategories: [
- Em.Object.create({hostComponentNames: ['comp1']})
- ],
- hostComponents: []
- },
- result: []
- },
- {
- title: 'Host components do not match component of categories',
- content: {
- configCategories: [
- Em.Object.create({hostComponentNames: ['comp1']})
- ],
- hostComponents: [
- {
- componentName: 'comp2'
- }
- ]
- },
- result: []
- },
- {
- title: 'Host components match component of categories',
- content: {
- configCategories: [
- Em.Object.create({hostComponentNames: ['comp1']})
- ],
- hostComponents: [
- {
- componentName: 'comp1'
- }
- ]
- },
- result: [
- Em.Object.create({hostComponentNames: ['comp1']})
- ]
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- controller.set('host.hostComponents', test.content.hostComponents);
- expect(controller.filterServiceConfigs(test.content.configCategories)).to.eql(test.result);
- });
- });
- });
- describe("#loadStep()", function () {
- it("should set host", function () {
- controller.set('content', {
- host: 'host1'
- });
- controller.loadStep();
- expect(controller.get('host')).to.be.equal('host1');
- });
- });
- describe("#renderServiceConfigs()", function () {
- it("should call filterServiceConfigs", function () {
- var serviceConfigs = {
- configCategories: 'val'
- };
- sinon.stub(controller, 'filterServiceConfigs', function () {
- this._super = Em.K;
- });
- controller.renderServiceConfigs(serviceConfigs);
- expect(controller.filterServiceConfigs.calledWith('val')).to.be.true;
- controller.filterServiceConfigs.restore();
- });
- });
- describe("#switchHostGroup()", function () {
- beforeEach(function() {
- sinon.stub(controller, 'launchSwitchConfigGroupOfHostDialog', Em.K);
- sinon.stub(controller, 'onConfigGroupChange', Em.K);
- });
- afterEach(function () {
- controller.launchSwitchConfigGroupOfHostDialog.restore();
- controller.onConfigGroupChange.restore();
- });
- it("should call launchSwitchConfigGroupOfHostDialog", function () {
- controller.set('selectedConfigGroup', {});
- controller.set('configGroups', []);
- controller.set('host', {hostName: 'host1'});
- controller.switchHostGroup();
- expect(controller.launchSwitchConfigGroupOfHostDialog.calledWith({}, [], 'host1')).to.be.true;
- });
- });
- });
|