dashboard_test.js 3.7 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('messages');
  20. var filters = require('views/common/filter_view');
  21. require('views/main/dashboard');
  22. describe('App.MainDashboardView', function() {
  23. var mainDashboardView = App.MainDashboardView.create();
  24. describe('#setInitPrefObject', function() {
  25. var hdfs_widgets_count = 7;
  26. var mapreduce_widgets_count = 7;
  27. var hbase_widgets_count = 4;
  28. var yarn_widgets_count = 4;
  29. var total_widgets_count = 27;
  30. var tests = [
  31. {
  32. models: {
  33. hdfs_model: null,
  34. mapreduce_model: null,
  35. hbase_model: null,
  36. yarn_model: null
  37. },
  38. e: {
  39. visibleL: total_widgets_count - hdfs_widgets_count - mapreduce_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
  40. hiddenL: 0
  41. },
  42. m: 'All models are null'
  43. },
  44. {
  45. models: {
  46. hdfs_model: {},
  47. mapreduce_model: null,
  48. hbase_model: null,
  49. yarn_model: null
  50. },
  51. e: {
  52. visibleL: total_widgets_count - mapreduce_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
  53. hiddenL: 0
  54. },
  55. m: 'mapreduce_model, hbase_model, yarn_model are null'
  56. },
  57. {
  58. models: {
  59. hdfs_model: {},
  60. mapreduce_model: {},
  61. hbase_model: null,
  62. yarn_model: null
  63. },
  64. e: {
  65. visibleL: total_widgets_count - hbase_widgets_count - yarn_widgets_count - 1,
  66. hiddenL: 0
  67. },
  68. m: 'hbase_model and yarn_model are null'
  69. },
  70. {
  71. models: {
  72. hdfs_model: {},
  73. mapreduce_model: {},
  74. hbase_model: {},
  75. yarn_model: null
  76. },
  77. e: {
  78. visibleL: total_widgets_count - yarn_widgets_count - 1,
  79. hiddenL: 1
  80. },
  81. m: 'yarn_model is null'
  82. },
  83. {
  84. models: {
  85. hdfs_model: {},
  86. mapreduce_model: {},
  87. hbase_model: {},
  88. yarn_model: {}
  89. },
  90. e: {
  91. visibleL: total_widgets_count - 1,
  92. hiddenL: 1
  93. },
  94. m: 'All models are not null'
  95. }
  96. ];
  97. tests.forEach(function(test) {
  98. it(test.m, function() {
  99. mainDashboardView.set('hdfs_model', test.models.hdfs_model);
  100. mainDashboardView.set('mapreduce_model', test.models.mapreduce_model);
  101. mainDashboardView.set('hbase_model', test.models.hbase_model);
  102. mainDashboardView.set('yarn_model', test.models.yarn_model);
  103. mainDashboardView.setInitPrefObject();
  104. expect(mainDashboardView.get('initPrefObject.visible.length')).to.equal(test.e.visibleL);
  105. expect(mainDashboardView.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL);
  106. });
  107. });
  108. });
  109. describe('#persistKey', function() {
  110. App.router.set('loginName', 'tdk');
  111. it('Check it', function() {
  112. expect(mainDashboardView.get('persistKey')).to.equal('user-pref-tdk-dashboard');
  113. });
  114. });
  115. });