add_controller_test.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/wizard');
  20. require('controllers/main/service/add_controller');
  21. describe('App.AddServiceController', function() {
  22. describe('#isServiceConfigurable', function() {
  23. var tests = [
  24. {
  25. services: [
  26. {serviceName: 'HDFS'},
  27. {serviceName: 'MAPREDUCE'},
  28. {serviceName: 'NAGIOS'}
  29. ],
  30. service: 'HDFS',
  31. m: 'Service is configurable',
  32. e: true
  33. },
  34. {
  35. services: [
  36. {serviceName: 'HDFS'},
  37. {serviceName: 'MAPREDUCE'},
  38. {serviceName: 'NAGIOS'}
  39. ],
  40. service: 'PIG',
  41. m: 'Service is not configurable',
  42. e: false
  43. },
  44. {
  45. services: [],
  46. service: 'HDFS',
  47. m: 'No services',
  48. e: false
  49. }
  50. ];
  51. tests.forEach(function(test) {
  52. var controller = App.AddServiceController.create({serviceConfigs: test.services});
  53. it('', function() {
  54. expect(controller.isServiceConfigurable(test.service)).to.equal(test.e);
  55. });
  56. });
  57. });
  58. describe('#skipConfigStep', function() {
  59. var tests = [
  60. {
  61. content: {
  62. services:[
  63. {serviceName: 'HDFS', isInstalled: true, isSelected: true},
  64. {serviceName: 'PIG', isInstalled: false, isSelected: true},
  65. {serviceName: 'MAPREDUCE', isInstalled: true, isSelected: true}
  66. ]
  67. },
  68. serviceConfigs: [
  69. {serviceName: 'HDFS'},
  70. {serviceName: 'MAPREDUCE'},
  71. {serviceName: 'NAGIOS'}
  72. ],
  73. m: '2 installed services and 1 new that can\'t be configured',
  74. e: true
  75. },
  76. {
  77. content: {
  78. services:[
  79. {serviceName: 'HDFS', isInstalled: true, isSelected: true},
  80. {serviceName: 'NAGIOS', isInstalled: false, isSelected: true},
  81. {serviceName: 'MAPREDUCE', isInstalled: true, isSelected: true}
  82. ]
  83. },
  84. serviceConfigs: [
  85. {serviceName: 'HDFS'},
  86. {serviceName: 'MAPREDUCE'},
  87. {serviceName: 'NAGIOS'}
  88. ],
  89. m: '2 installed services and 1 new that can be configured',
  90. e: false
  91. },
  92. {
  93. content: {
  94. services:[
  95. {serviceName: 'HDFS', isInstalled: true, isSelected: true},
  96. {serviceName: 'PIG', isInstalled: false, isSelected: true},
  97. {serviceName: 'SQOOP', isInstalled: false, isSelected: true},
  98. {serviceName: 'MAPREDUCE', isInstalled: true, isSelected: true}
  99. ]
  100. },
  101. serviceConfigs: [
  102. {serviceName: 'HDFS'},
  103. {serviceName: 'MAPREDUCE'},
  104. {serviceName: 'NAGIOS'}
  105. ],
  106. m: '2 installed services and 2 new that can\'t be configured',
  107. e: true
  108. }
  109. ];
  110. tests.forEach(function(test) {
  111. var controller = App.AddServiceController.create({content:{services: test.content.services}, serviceConfigs: test.serviceConfigs});
  112. it(test.m, function() {
  113. expect(controller.skipConfigStep()).to.equal(test.e);
  114. })
  115. });
  116. });
  117. });