step7_controller_test.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. App = require('app');
  19. require('controllers/main/service/reassign/step7_controller');
  20. var controller;
  21. var testHelpers = require('test/helpers');
  22. describe('App.ReassignMasterWizardStep7Controller', function () {
  23. beforeEach(function () {
  24. controller = App.ReassignMasterWizardStep7Controller.create({
  25. content: Em.Object.create({
  26. reassign: Em.Object.create(),
  27. reassignHosts: Em.Object.create()
  28. })
  29. });
  30. });
  31. describe('#initializeTasks()', function () {
  32. it('should set isLoaded to true', function () {
  33. controller.set('isLoaded', false);
  34. controller.initializeTasks();
  35. expect(controller.get('isLoaded')).to.be.true;
  36. });
  37. });
  38. describe("#putHostComponentsInMaintenanceMode()", function() {
  39. it("no host-components", function() {
  40. controller.set('hostComponents', []);
  41. controller.putHostComponentsInMaintenanceMode();
  42. var args = testHelpers.findAjaxRequest('name', 'common.host.host_component.passive');
  43. expect(args).not.exists;
  44. expect(controller.get('multiTaskCounter')).to.equal(0);
  45. });
  46. it("one host-component", function() {
  47. controller.set('hostComponents', ['C1']);
  48. controller.set('content.reassignHosts.target', 'host1');
  49. controller.putHostComponentsInMaintenanceMode();
  50. var args = testHelpers.findAjaxRequest('name', 'common.host.host_component.passive');
  51. expect(args[0]).exists;
  52. expect(args[0].sender).to.be.eql(controller);
  53. expect(args[0].data).to.be.eql({
  54. hostName: 'host1',
  55. passive_state: "ON",
  56. componentName: 'C1'
  57. });
  58. expect(controller.get('multiTaskCounter')).to.equal(0);
  59. });
  60. it("two host-components", function() {
  61. controller.set('hostComponents', ['C1', 'C2']);
  62. controller.putHostComponentsInMaintenanceMode();
  63. var args = testHelpers.filterAjaxRequests('name', 'common.host.host_component.passive');
  64. expect(args).to.have.property('length').equal(2);
  65. expect(controller.get('multiTaskCounter')).to.equal(0);
  66. });
  67. });
  68. describe("#deleteHostComponents()", function() {
  69. it("no host-components", function() {
  70. controller.set('hostComponents', []);
  71. controller.deleteHostComponents();
  72. var args = testHelpers.findAjaxRequest('name', 'common.delete.host_component');
  73. expect(args).not.exists;
  74. expect(controller.get('multiTaskCounter')).to.equal(0);
  75. });
  76. it("one host-component", function() {
  77. controller.set('hostComponents', ['C1']);
  78. controller.set('content.reassignHosts.target', 'host1');
  79. controller.deleteHostComponents();
  80. var args = testHelpers.findAjaxRequest('name', 'common.delete.host_component');
  81. expect(args[0]).exists;
  82. expect(args[0].sender).to.be.eql(controller);
  83. expect(args[0].data).to.be.eql({
  84. hostName: 'host1',
  85. componentName: 'C1'
  86. });
  87. expect(controller.get('multiTaskCounter')).to.equal(0);
  88. });
  89. it("two host-components", function() {
  90. controller.set('hostComponents', ['C1', 'C2']);
  91. controller.deleteHostComponents();
  92. var args = testHelpers.filterAjaxRequests('name', 'common.delete.host_component');
  93. expect(args).to.have.property('length').equal(2);
  94. expect(controller.get('multiTaskCounter')).to.equal(0);
  95. });
  96. });
  97. });