reassign_controller_test.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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('models/cluster');
  20. require('controllers/wizard');
  21. require('controllers/main/service/reassign_controller');
  22. describe('App.ReassignMasterController', function () {
  23. var reassignMasterController;
  24. beforeEach(function () {
  25. reassignMasterController = App.ReassignMasterController.create({});
  26. });
  27. describe('#totalSteps', function () {
  28. it('check', function () {
  29. expect(reassignMasterController.get('totalSteps')).to.equal(7);
  30. reassignMasterController.set('content.reassign', {service_id:null});
  31. });
  32. });
  33. describe('#saveMasterComponentHosts', function () {
  34. var stepController = Em.Object.create({
  35. selectedServicesMasters: [
  36. Em.Object.create({
  37. display_name: 'd0',
  38. component_name: 'c0',
  39. selectedHost: 'h0',
  40. serviceId: 's0'
  41. }),
  42. Em.Object.create({
  43. display_name: 'd1',
  44. component_name: 'c1',
  45. selectedHost: 'h1',
  46. serviceId: 's1'
  47. })
  48. ]
  49. }),
  50. masterComponentHosts = [
  51. {
  52. display_name: 'd0',
  53. component: 'c0',
  54. hostName: 'h0',
  55. serviceId: 's0',
  56. isInstalled: true
  57. },
  58. {
  59. display_name: 'd1',
  60. component: 'c1',
  61. hostName: 'h1',
  62. serviceId: 's1',
  63. isInstalled: true
  64. }
  65. ];
  66. beforeEach(function () {
  67. sinon.stub(App.db, 'setMasterComponentHosts', Em.K);
  68. sinon.stub(reassignMasterController, 'setDBProperty', Em.K);
  69. });
  70. afterEach(function () {
  71. App.db.setMasterComponentHosts.restore();
  72. reassignMasterController.setDBProperty.restore();
  73. });
  74. it('should save master component hosts', function () {
  75. reassignMasterController.saveMasterComponentHosts(stepController);
  76. expect(App.db.setMasterComponentHosts.calledOnce).to.be.true;
  77. expect(reassignMasterController.setDBProperty.calledOnce).to.be.true;
  78. expect(App.db.setMasterComponentHosts.calledWith(masterComponentHosts)).to.be.true;
  79. expect(reassignMasterController.setDBProperty.calledWith('masterComponentHosts', masterComponentHosts)).to.be.true;
  80. expect(reassignMasterController.get('content.masterComponentHosts')).to.eql(masterComponentHosts);
  81. });
  82. });
  83. });