step2_view_test.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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/step2_view');
  20. var view, controller = Em.Object.create({
  21. clusterNameError: ''
  22. });
  23. function getView() {
  24. return App.WizardStep2View.create({'controller': controller});
  25. }
  26. describe('App.WizardStep0View', function () {
  27. beforeEach(function() {
  28. view = getView();
  29. });
  30. App.TestAliases.testAsComputedAlias(getView(), 'sshKeyState', 'controller.content.installOptions.manualInstall', 'string');
  31. describe('#didInsertElement', function() {
  32. beforeEach(function () {
  33. sinon.stub(App, 'popover', Em.K);
  34. sinon.stub(App, 'tooltip', Em.K);
  35. view.set('controller.hostsError', 'some text');
  36. view.set('controller.sshKeyError', 'some text');
  37. });
  38. afterEach(function () {
  39. App.popover.restore();
  40. App.tooltip.restore();
  41. });
  42. it('should clean hostsError', function () {
  43. view.didInsertElement();
  44. expect(view.get('controller.hostsError')).to.be.null;
  45. });
  46. it('should clean sshKeyError', function () {
  47. view.didInsertElement();
  48. expect(view.get('controller.sshKeyError')).to.be.null;
  49. });
  50. it('should create popover', function () {
  51. view.didInsertElement();
  52. expect(App.popover.calledOnce).to.equal(true);
  53. });
  54. it('should create tooltip', function () {
  55. view.didInsertElement();
  56. expect(App.tooltip.calledOnce).to.equal(true);
  57. });
  58. });
  59. describe('#providingSSHKeyRadioButton', function() {
  60. var v;
  61. beforeEach(function() {
  62. v = view.get('providingSSHKeyRadioButton').create({
  63. controller: Em.Object.create({
  64. content: {
  65. installOptions: {
  66. useSsh: true,
  67. manualInstall: true
  68. }
  69. }
  70. })
  71. });
  72. });
  73. describe('#checked', function() {
  74. it('should be equal to controller.content.installOptions.useSsh', function () {
  75. v.set('controller.content.installOptions.useSsh', false);
  76. expect(v.get('checked')).to.equal(false);
  77. v.set('controller.content.installOptions.useSsh', true);
  78. expect(v.get('checked')).to.equal(true);
  79. });
  80. });
  81. describe('#click', function() {
  82. it('should update controller.content.installOptions.useSsh', function () {
  83. v.set('controller.content.installOptions.useSsh', false);
  84. v.click();
  85. expect(v.get('controller.content.installOptions.useSsh')).to.equal(true);
  86. });
  87. it('should update controller.content.installOptions.manualInstall', function () {
  88. v.set('controller.content.installOptions.manualInstall', true);
  89. v.click();
  90. expect(v.get('controller.content.installOptions.manualInstall')).to.equal(false);
  91. });
  92. });
  93. });
  94. describe('#manualRegistrationRadioButton', function() {
  95. var v;
  96. beforeEach(function() {
  97. v = view.get('manualRegistrationRadioButton').create({
  98. controller: Em.Object.create({
  99. content: {
  100. installOptions: {
  101. useSsh: true,
  102. manualInstall: true
  103. }
  104. }
  105. })
  106. });
  107. });
  108. describe('#checked', function() {
  109. it('should be equal to controller.content.installOptions.manualInstall', function () {
  110. v.set('controller.content.installOptions.manualInstall', false);
  111. expect(v.get('checked')).to.equal(false);
  112. v.set('controller.content.installOptions.manualInstall', true);
  113. expect(v.get('checked')).to.equal(true);
  114. });
  115. });
  116. describe('#click', function() {
  117. it('should update controller.content.installOptions.useSsh', function () {
  118. v.set('controller.content.installOptions.useSsh', true);
  119. v.click();
  120. expect(v.get('controller.content.installOptions.useSsh')).to.equal(false);
  121. });
  122. it('should update controller.content.installOptions.manualInstall', function () {
  123. v.set('controller.content.installOptions.manualInstall', false);
  124. v.click();
  125. expect(v.get('controller.content.installOptions.manualInstall')).to.equal(true);
  126. });
  127. });
  128. });
  129. describe('#textFieldView', function() {
  130. var v;
  131. beforeEach(function() {
  132. v = view.get('textFieldView').create();
  133. });
  134. describe('#disabled', function() {
  135. it('should be inverted to isEnabled', function () {
  136. v.set('isEnabled', false);
  137. expect(v.get('disabled')).to.equal(true);
  138. v.set('isEnabled', true);
  139. expect(v.get('disabled')).to.equal(false);
  140. });
  141. });
  142. });
  143. });
  144. describe('App.SshKeyFileUploader', function() {
  145. beforeEach(function() {
  146. view = App.SshKeyFileUploader.create();
  147. });
  148. });