wizard_test.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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('models/cluster');
  20. require('controllers/wizard');
  21. describe('App.WizardController', function () {
  22. var wizardController = App.WizardController.create({});
  23. var totalSteps = 11;
  24. var ruller = [];
  25. for(var i = 0; i < totalSteps; i++) {
  26. ruller.push(i);
  27. }
  28. describe('#setLowerStepsDisable', function() {
  29. for(var i = 1; i < totalSteps; i++) {
  30. var indx = i;
  31. var steps = [];
  32. for(var j = 1; j <= indx; j++) {
  33. steps.push(Em.Object.create({step:j,value:false}));
  34. }
  35. wizardController.set('isStepDisabled', steps);
  36. for(j = 1; j <= indx; j++) {
  37. it('Steps: ' + i + ' | Disabled: ' + (j-1), function() {
  38. wizardController.setLowerStepsDisable(j);
  39. expect(wizardController.get('isStepDisabled').filterProperty('value', true).length).to.equal(j-1);
  40. });
  41. }
  42. }
  43. });
  44. // isStep0 ... isStep10 tests
  45. App.WizardController1 = App.WizardController.extend({currentStep:''});
  46. var tests = [];
  47. for(var i = 0; i < totalSteps; i++) {
  48. var n = ruller.slice(0);
  49. n.splice(i,1);
  50. tests.push({i:i,n:n});
  51. }
  52. tests.forEach(function(test) {
  53. describe('isStep'+test.i, function() {
  54. var w = App.WizardController1.create();
  55. w.set('currentStep', test.i);
  56. it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function() {
  57. expect(w.get('isStep'+ test.i)).to.equal(true);
  58. });
  59. test.n.forEach(function(indx) {
  60. it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function() {
  61. expect(w.get('isStep'+ indx)).to.equal(false);
  62. });
  63. });
  64. });
  65. });
  66. // isStep0 ... isStep10 tests end
  67. describe('#gotoStep', function() {
  68. var w = App.WizardController1.create();
  69. var steps = [];
  70. for(var j = 0; j < totalSteps; j++) {
  71. steps.push(Em.Object.create({step:j,value:false}));
  72. }
  73. steps.forEach(function(step, index) {
  74. step.set('value', true);
  75. w.set('isStepDisabled', steps);
  76. it('step ' + index + ' is disabled, so gotoStep('+index+') is not possible', function() {
  77. expect(w.gotoStep(index)).to.equal(false);
  78. });
  79. });
  80. });
  81. describe('#launchBootstrapSuccessCallback', function() {
  82. it('Save bootstrapRequestId', function() {
  83. var data = {requestId: 123};
  84. var params = {popup: {finishLoading: function(){}}};
  85. sinon.spy(params.popup, "finishLoading");
  86. wizardController.launchBootstrapSuccessCallback(data, {}, params);
  87. expect(params.popup.finishLoading.calledWith(123)).to.be.true;
  88. params.popup.finishLoading.restore();
  89. });
  90. });
  91. });