node_managers_live_test.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/widget');
  21. require('views/main/dashboard/widgets/text_widget');
  22. require('views/main/dashboard/widgets/node_managers_live');
  23. describe('App.NodeManagersLiveView', function() {
  24. var tests = [
  25. {
  26. model: {
  27. nodeManagersTotal: 3,
  28. nodeManagerLiveNodes: 2
  29. },
  30. e: {
  31. isRed: false,
  32. isOrange: true,
  33. isGreen: false,
  34. isNA: false,
  35. content: '2/3',
  36. data: 67
  37. }
  38. },
  39. {
  40. model: {
  41. nodeManagersTotal: 2,
  42. nodeManagerLiveNodes: 2
  43. },
  44. e: {
  45. isRed: false,
  46. isOrange: false,
  47. isGreen: true,
  48. isNA: false,
  49. content: '2/2',
  50. data: 100
  51. }
  52. },
  53. {
  54. model: {
  55. nodeManagersTotal: 2,
  56. nodeManagerLiveNodes: 0
  57. },
  58. e: {
  59. isRed: true,
  60. isOrange: false,
  61. isGreen: false,
  62. isNA: false,
  63. content: '0/2',
  64. data: 0.00
  65. }
  66. }
  67. ];
  68. tests.forEach(function(test) {
  69. describe('nodeManagerNodes length - ' + test.model.nodeManagersTotal + ' | nodeManagerLiveNodes length - ' + test.model.nodeManagerLiveNodes, function() {
  70. var AppNodeManagersLiveView = App.NodeManagersLiveView.extend({nodeManagersLive: test.model.nodeManagerLiveNodes});
  71. var nodeManagersLiveView = AppNodeManagersLiveView.create({model_type:null, model: test.model});
  72. it('content', function() {
  73. expect(nodeManagersLiveView.get('content')).to.equal(test.e.content);
  74. });
  75. it('data', function() {
  76. expect(nodeManagersLiveView.get('data')).to.equal(test.e.data);
  77. });
  78. it('isRed', function() {
  79. expect(nodeManagersLiveView.get('isRed')).to.equal(test.e.isRed);
  80. });
  81. it('isOrange', function() {
  82. expect(nodeManagersLiveView.get('isOrange')).to.equal(test.e.isOrange);
  83. });
  84. it('isGreen', function() {
  85. expect(nodeManagersLiveView.get('isGreen')).to.equal(test.e.isGreen);
  86. });
  87. it('isNA', function() {
  88. expect(nodeManagersLiveView.get('isNA')).to.equal(test.e.isNA);
  89. });
  90. });
  91. });
  92. });