step2_test.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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('controllers/main/admin/security/add/step2');
  20. require('utils/polling');
  21. require('models/cluster_states');
  22. describe('App.MainAdminSecurityAddStep2Controller', function () {
  23. var mainAdminSecurityAddStep2Controller = App.MainAdminSecurityAddStep2Controller.create();
  24. describe('#clearStep', function() {
  25. mainAdminSecurityAddStep2Controller.set('stepConfigs',[1,2,3]);
  26. it('clear', function() {
  27. mainAdminSecurityAddStep2Controller.clearStep();
  28. expect(mainAdminSecurityAddStep2Controller.get('stepConfigs.length')).to.equal(0);
  29. });
  30. });
  31. describe('#isSubmitDisabled', function() {
  32. var tests = [
  33. {
  34. config:[
  35. {
  36. showConfig: true,
  37. errorCount: 0
  38. }
  39. ],
  40. m: 'All show configs, nothing with errors',
  41. e: false
  42. },
  43. {
  44. config:[
  45. {
  46. showConfig: true,
  47. errorCount: 0
  48. },
  49. {
  50. showConfig: true,
  51. errorCount: 1
  52. }
  53. ],
  54. m: 'All show configs, 1 with errors',
  55. e: true
  56. },
  57. {
  58. config:[
  59. {
  60. showConfig: true,
  61. errorCount: 0
  62. },
  63. {
  64. showConfig: false,
  65. errorCount: 1
  66. }
  67. ],
  68. m: '1 has errors but not visible',
  69. e: false
  70. },
  71. {
  72. config:[
  73. {
  74. showConfig: false,
  75. errorCount: 0
  76. },
  77. {
  78. showConfig: false,
  79. errorCount: 1
  80. }
  81. ],
  82. m: '1 has errors, all not visible',
  83. e: false
  84. },
  85. {
  86. config:[
  87. {
  88. showConfig: true,
  89. errorCount: 1
  90. },
  91. {
  92. showConfig: true,
  93. errorCount: 1
  94. }
  95. ],
  96. m: 'All has errors, all not visible',
  97. e: true
  98. }
  99. ];
  100. tests.forEach(function(test) {
  101. it(test.m, function() {
  102. mainAdminSecurityAddStep2Controller.set('stepConfigs', test.config);
  103. expect(mainAdminSecurityAddStep2Controller.get('isSubmitDisabled')).to.equal(test.e);
  104. });
  105. });
  106. });
  107. });