stack_and_upgrade_controller_test.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. var controller;
  20. require('controllers/main/admin/stack_and_upgrade_controller');
  21. describe('App.MainAdminStackAndUpgradeController', function() {
  22. beforeEach(function() {
  23. controller = App.MainAdminStackAndUpgradeController.create({});
  24. });
  25. describe("#services", function () {
  26. before(function () {
  27. sinon.stub(App.StackService, 'find').returns([
  28. Em.Object.create({serviceName: 'S1', isInstalled: false}),
  29. Em.Object.create({serviceName: 'S2', isInstalled: false})
  30. ]);
  31. sinon.stub(App.Service, 'find').returns([
  32. Em.Object.create({serviceName: 'S1'})
  33. ]);
  34. });
  35. after(function () {
  36. App.StackService.find.restore();
  37. App.Service.find.restore();
  38. });
  39. it("", function () {
  40. controller.propertyDidChange('services');
  41. expect(controller.get('services')).to.eql([
  42. Em.Object.create({serviceName: 'S1', isInstalled: true}),
  43. Em.Object.create({serviceName: 'S2', isInstalled: false})
  44. ])
  45. });
  46. });
  47. describe("#goToAddService()" , function() {
  48. beforeEach(function() {
  49. sinon.stub(App.get('router'), 'transitionTo', Em.K);
  50. });
  51. afterEach(function() {
  52. App.get('router').transitionTo.restore();
  53. });
  54. it("routes to Add Service Wizard", function() {
  55. controller.goToAddService({context: "serviceName"});
  56. expect(App.get('router').transitionTo.calledOnce).to.be.true;
  57. expect(controller.get('serviceToInstall')).to.be.equal("serviceName");
  58. });
  59. });
  60. describe("#loadVersionsInfo()", function() {
  61. before(function () {
  62. sinon.stub(App.ajax, 'send', Em.K);
  63. });
  64. after(function () {
  65. App.ajax.send.restore();
  66. });
  67. it("make ajax call", function() {
  68. controller.loadVersionsInfo();
  69. expect(App.ajax.send.getCall(0).args[0]).to.eql({
  70. name: 'admin.stack_versions.all',
  71. sender: controller,
  72. data: {},
  73. success: 'loadVersionsInfoSuccessCallback'
  74. })
  75. });
  76. });
  77. describe("#loadVersionsInfoSuccessCallback()", function() {
  78. it("", function() {
  79. var data = {"items": [
  80. {
  81. "ClusterStackVersions": {
  82. "state": "CURRENT"
  83. }
  84. },
  85. {
  86. "ClusterStackVersions": {
  87. "state": "INSTALLED"
  88. }
  89. }
  90. ]};
  91. controller.loadVersionsInfoSuccessCallback(data);
  92. expect(controller.get('currentVersion')).to.eql({
  93. "state": "CURRENT"
  94. });
  95. expect(controller.get('targetVersions')).to.eql([{
  96. "state": "INSTALLED"
  97. }]);
  98. });
  99. });
  100. });