assign_master_view_test.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('views/wizard/step9/hostLogPopupBody_view');
  20. var stringUtils = require('utils/string_utils');
  21. var view;
  22. function getView() {
  23. return App.AssignMasterOnStep7View.create({
  24. controller: Em.Object.create()
  25. });
  26. }
  27. describe('App.AssignMasterOnStep7View', function() {
  28. beforeEach(function() {
  29. view = getView();
  30. });
  31. describe("#willInsertElement()", function () {
  32. beforeEach(function() {
  33. sinon.stub(view, 'setAlertMessage');
  34. });
  35. afterEach(function() {
  36. view.setAlertMessage.restore();
  37. });
  38. it("setAlertMessage should be called", function() {
  39. view.willInsertElement();
  40. expect(view.setAlertMessage.calledOnce).to.be.true;
  41. });
  42. });
  43. describe("#getDependentComponents()", function () {
  44. beforeEach(function() {
  45. sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({
  46. dependencies: [{
  47. scope: 'host',
  48. componentName: 'C1'
  49. }]
  50. }));
  51. sinon.stub(App.format, 'role', function(arg) {
  52. return arg;
  53. });
  54. });
  55. afterEach(function() {
  56. App.StackServiceComponent.find.restore();
  57. App.format.role.restore();
  58. });
  59. it("should return dependent components", function() {
  60. expect(view.getDependentComponents([{}])).to.be.eql(['C1']);
  61. });
  62. });
  63. describe("#setAlertMessage()", function () {
  64. beforeEach(function() {
  65. sinon.stub(App.format, 'role', function(arg) {
  66. return arg;
  67. });
  68. sinon.stub(view, 'getDependentComponents').returns(['c1']);
  69. sinon.stub(stringUtils, 'getFormattedStringFromArray').returns('');
  70. this.mock = sinon.stub(App, 'get');
  71. });
  72. afterEach(function() {
  73. App.format.role.restore();
  74. view.getDependentComponents.restore();
  75. stringUtils.getFormattedStringFromArray.restore();
  76. this.mock.restore();
  77. });
  78. it("isManualKerberos false, single master", function() {
  79. var expected = Em.I18n.t('installer.step7.assign.master.body')
  80. .format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')) +
  81. '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('');
  82. view.set('controller.mastersToCreate', ['c1']);
  83. this.mock.returns(false);
  84. view.setAlertMessage();
  85. expect(view.get('alertMessage')).to.be.equal(expected);
  86. });
  87. it("isManualKerberos false, multiple masters", function() {
  88. var expected = Em.I18n.t('installer.step7.assign.master.body')
  89. .format('c1,c2', Em.I18n.t('common.hosts').toLowerCase(), Em.I18n.t('then')) +
  90. '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('');
  91. view.set('controller.mastersToCreate', ['c1', 'c2']);
  92. this.mock.returns(false);
  93. view.setAlertMessage();
  94. expect(view.get('alertMessage')).to.be.equal(expected);
  95. });
  96. it("isManualKerberos true, single master", function() {
  97. var expected = Em.I18n.t('installer.step7.assign.master.body')
  98. .format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')) +
  99. '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('') +
  100. '<br/>' + Em.I18n.t('common.warn.message').format(Em.I18n.t('common.important') + ': ' + Em.I18n.t('installer.step8.kerberors.warning'));
  101. view.set('controller.mastersToCreate', ['c1']);
  102. this.mock.returns(true);
  103. view.setAlertMessage();
  104. expect(view.get('alertMessage')).to.be.equal(expected);
  105. });
  106. });
  107. });