hbase_average_load_test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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('messages');
  20. require('views/main/dashboard/widgets/hbase_average_load');
  21. require('views/main/dashboard/widgets/text_widget');
  22. require('views/main/dashboard/widget');
  23. function getView() {
  24. return App.HBaseAverageLoadView.create({model_type: null});
  25. }
  26. describe('App.HBaseAverageLoadView', function() {
  27. var tests = [
  28. {
  29. model: {
  30. averageLoad: 1
  31. },
  32. e: {
  33. isRed: false,
  34. isOrange: true,
  35. isGreen: false,
  36. isNA: false,
  37. content: '1'
  38. }
  39. },
  40. {
  41. model: {
  42. averageLoad: 10
  43. },
  44. e: {
  45. isRed: true,
  46. isOrange: false,
  47. isGreen: false,
  48. isNA: false,
  49. content: '10'
  50. }
  51. },
  52. {
  53. model: {
  54. averageLoad: 0
  55. },
  56. e: {
  57. isRed: false,
  58. isOrange: false,
  59. isGreen: true,
  60. isNA: false,
  61. content: '0'
  62. }
  63. },
  64. {
  65. model: {
  66. averageLoad: null
  67. },
  68. e: {
  69. isRed: false,
  70. isOrange: false,
  71. isGreen: true,
  72. isNA: true,
  73. content: Em.I18n.t('services.service.summary.notAvailable')
  74. }
  75. }
  76. ];
  77. tests.forEach(function(test) {
  78. describe('averageLoad - ' + test.model.averageLoad, function() {
  79. var hBaseAverageLoadView = App.HBaseAverageLoadView.create({model_type:null, model: test.model});
  80. it('content', function() {
  81. expect(hBaseAverageLoadView.get('content')).to.equal(test.e.content);
  82. });
  83. it('data', function() {
  84. expect(hBaseAverageLoadView.get('data')).to.equal(test.model.averageLoad);
  85. });
  86. it('isRed', function() {
  87. expect(hBaseAverageLoadView.get('isRed')).to.equal(test.e.isRed);
  88. });
  89. it('isOrange', function() {
  90. expect(hBaseAverageLoadView.get('isOrange')).to.equal(test.e.isOrange);
  91. });
  92. it('isGreen', function() {
  93. expect(hBaseAverageLoadView.get('isGreen')).to.equal(test.e.isGreen);
  94. });
  95. it('isNA', function() {
  96. expect(hBaseAverageLoadView.get('isNA')).to.equal(test.e.isNA);
  97. });
  98. });
  99. });
  100. App.TestAliases.testAsComputedAlias(getView(), 'data', 'model.averageLoad', 'number');
  101. App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2');
  102. App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1');
  103. });