service_test.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/service');
  20. var mainServiceController;
  21. describe('App.MainServiceController', function () {
  22. var tests = Em.A([
  23. {
  24. isStartStopAllClicked: false,
  25. content: Em.A([
  26. Em.Object.create({
  27. healthStatus: 'green',
  28. serviceName: 'HIVE',
  29. isClientsOnly: false
  30. }),
  31. Em.Object.create({
  32. healthStatus: 'green',
  33. serviceName: 'HDFS',
  34. isClientsOnly: false
  35. }),
  36. Em.Object.create({
  37. healthStatus: 'red',
  38. serviceName: 'TEZ',
  39. isClientsOnly: true
  40. })
  41. ]),
  42. eStart: true,
  43. eStop: false,
  44. mStart: 'mainServiceController StartAll is Disabled 1',
  45. mStop: 'mainServiceController StopAll is Enabled 1'
  46. },
  47. {
  48. isStartStopAllClicked: true,
  49. content: Em.A([
  50. Em.Object.create({
  51. healthStatus: 'red',
  52. serviceName: 'HIVE',
  53. isClientsOnly: false
  54. }),
  55. Em.Object.create({
  56. healthStatus: 'red',
  57. serviceName: 'HDFS',
  58. isClientsOnly: false
  59. }),
  60. Em.Object.create({
  61. healthStatus: 'red',
  62. serviceName: 'TEZ',
  63. isClientsOnly: true
  64. })
  65. ]),
  66. eStart: true,
  67. eStop: true,
  68. mStart: 'mainServiceController StartAll is Disabled 2',
  69. mStop: 'mainServiceController StopAll is Disabled 2'
  70. },
  71. {
  72. isStartStopAllClicked: false,
  73. content: Em.A([
  74. Em.Object.create({
  75. healthStatus: 'green',
  76. serviceName: 'HIVE',
  77. isClientsOnly: false
  78. }),
  79. Em.Object.create({
  80. healthStatus: 'red',
  81. serviceName: 'HDFS',
  82. isClientsOnly: false
  83. }),
  84. Em.Object.create({
  85. healthStatus: 'red',
  86. serviceName: 'TEZ',
  87. isClientsOnly: true
  88. })
  89. ]),
  90. eStart: false,
  91. eStop: false,
  92. mStart: 'mainServiceController StartAll is Enabled 3',
  93. mStop: 'mainServiceController StopAll is Enabled 3'
  94. }
  95. ]);
  96. describe('#isStartAllDisabled', function () {
  97. tests.forEach(function (test) {
  98. it(test.mStart, function () {
  99. mainServiceController = App.MainServiceController.create({
  100. content: test.content,
  101. isStartStopAllClicked: test.isStartStopAllClicked
  102. });
  103. expect(mainServiceController.get('isStartAllDisabled')).to.equals(test.eStart);
  104. });
  105. });
  106. });
  107. describe('#isStopAllDisabled', function () {
  108. tests.forEach(function (test) {
  109. it(test.mStop, function () {
  110. mainServiceController = App.MainServiceController.create({
  111. content: test.content,
  112. isStartStopAllClicked: test.isStartStopAllClicked
  113. });
  114. expect(mainServiceController.get('isStopAllDisabled')).to.equals(test.eStop);
  115. });
  116. });
  117. });
  118. });