background_operations_test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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('config');
  20. require('utils/updater');
  21. require('utils/ajax');
  22. require('models/host_component');
  23. require('controllers/global/background_operations_controller');
  24. require('views/common/modal_popup');
  25. require('utils/host_progress_popup');
  26. var controller;
  27. describe('App.BackgroundOperationsController', function () {
  28. /**
  29. * Predefined data
  30. *
  31. */
  32. App.set('clusterName', 'testName');
  33. App.bgOperationsUpdateInterval = 100;
  34. var tests = Em.A([
  35. {
  36. levelInfo: Em.Object.create({
  37. name: 'REQUESTS_LIST',
  38. requestId: null,
  39. taskId: null,
  40. sync: false
  41. }),
  42. e: {
  43. name: 'background_operations.get_most_recent',
  44. successCallback: 'callBackForMostRecent',
  45. data: {}
  46. },
  47. response: {items:[]},
  48. m: '"Get Most Recent"'
  49. },
  50. {
  51. levelInfo: Em.Object.create({
  52. name: 'TASK_DETAILS',
  53. requestId: 1,
  54. taskId: 1,
  55. sync: false
  56. }),
  57. e: {
  58. name: 'background_operations.get_by_task',
  59. successCallback: 'callBackFilteredByTask',
  60. data: {
  61. taskId: 1,
  62. requestId: 1,
  63. sync: false
  64. }
  65. },
  66. response: {items:{Tasks:{request_id:0}}},
  67. m: '"Filtered By task"'
  68. },
  69. {
  70. levelInfo: Em.Object.create({
  71. name: 'TASKS_LIST',
  72. requestId: 1,
  73. taskId: 1,
  74. sync: false
  75. }),
  76. e: {
  77. name: 'background_operations.get_by_request',
  78. successCallback: 'callBackFilteredByRequest',
  79. data: {
  80. requestId: 1,
  81. sync: false
  82. }
  83. },
  84. response: {items:{Requests:{id:0}}},
  85. m: '"Filtered By Request (TASKS_LIST)"'
  86. },
  87. {
  88. levelInfo: Em.Object.create({
  89. name: 'HOSTS_LIST',
  90. requestId: 1,
  91. taskId: 1,
  92. sync: false
  93. }),
  94. e: {
  95. name: 'background_operations.get_by_request',
  96. successCallback: 'callBackFilteredByRequest',
  97. data: {
  98. requestId: 1,
  99. sync: false
  100. }
  101. },
  102. response: {items:{Requests:{id:0}}},
  103. m: '"Filtered By Request (HOSTS_LIST)"'
  104. }
  105. ]);
  106. describe('#getQueryParams', function() {
  107. beforeEach(function() {
  108. controller = App.BackgroundOperationsController.create();
  109. App.testMode = false;
  110. });
  111. afterEach(function() {
  112. App.testMode = true;
  113. });
  114. tests.forEach(function(test) {
  115. it(test.m, function() {
  116. controller.set('levelInfo', test.levelInfo);
  117. var r = controller.getQueryParams();
  118. expect(r.name).to.equal(test.e.name);
  119. expect(r.successCallback).to.equal(test.e.successCallback);
  120. expect(r.data).to.eql(test.e.data);
  121. });
  122. });
  123. });
  124. });