123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /**
- * 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/wizard/step9/hostLogPopupBody_view');
- var stringUtils = require('utils/string_utils');
- var view;
- function getView() {
- return App.AssignMasterOnStep7View.create({
- controller: Em.Object.create()
- });
- }
- describe('App.AssignMasterOnStep7View', function() {
- beforeEach(function() {
- view = getView();
- });
- describe("#willInsertElement()", function () {
- beforeEach(function() {
- sinon.stub(view, 'setAlertMessage');
- });
- afterEach(function() {
- view.setAlertMessage.restore();
- });
- it("setAlertMessage should be called", function() {
- view.willInsertElement();
- expect(view.setAlertMessage.calledOnce).to.be.true;
- });
- });
- describe("#getDependentComponents()", function () {
- beforeEach(function() {
- sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({
- dependencies: [{
- scope: 'host',
- componentName: 'C1'
- }]
- }));
- sinon.stub(App.format, 'role', function(arg) {
- return arg;
- });
- });
- afterEach(function() {
- App.StackServiceComponent.find.restore();
- App.format.role.restore();
- });
- it("should return dependent components", function() {
- expect(view.getDependentComponents([{}])).to.be.eql(['C1']);
- });
- });
- describe("#setAlertMessage()", function () {
- beforeEach(function() {
- sinon.stub(App.format, 'role', function(arg) {
- return arg;
- });
- sinon.stub(view, 'getDependentComponents').returns(['c1']);
- sinon.stub(stringUtils, 'getFormattedStringFromArray').returns('');
- this.mock = sinon.stub(App, 'get');
- });
- afterEach(function() {
- App.format.role.restore();
- view.getDependentComponents.restore();
- stringUtils.getFormattedStringFromArray.restore();
- this.mock.restore();
- });
- it("isManualKerberos false, single master", function() {
- var expected = Em.I18n.t('installer.step7.assign.master.body')
- .format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')) +
- '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('');
- view.set('controller.mastersToCreate', ['c1']);
- this.mock.returns(false);
- view.setAlertMessage();
- expect(view.get('alertMessage')).to.be.equal(expected);
- });
- it("isManualKerberos false, multiple masters", function() {
- var expected = Em.I18n.t('installer.step7.assign.master.body')
- .format('c1,c2', Em.I18n.t('common.hosts').toLowerCase(), Em.I18n.t('then')) +
- '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('');
- view.set('controller.mastersToCreate', ['c1', 'c2']);
- this.mock.returns(false);
- view.setAlertMessage();
- expect(view.get('alertMessage')).to.be.equal(expected);
- });
- it("isManualKerberos true, single master", function() {
- var expected = Em.I18n.t('installer.step7.assign.master.body')
- .format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')) +
- '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('') +
- '<br/>' + Em.I18n.t('common.warn.message').format(Em.I18n.t('common.important') + ': ' + Em.I18n.t('installer.step8.kerberors.warning'));
- view.set('controller.mastersToCreate', ['c1']);
- this.mock.returns(true);
- view.setAlertMessage();
- expect(view.get('alertMessage')).to.be.equal(expected);
- });
- });
- });
|