add_controller_test.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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('controllers/wizard');
  20. require('controllers/main/service/add_controller');
  21. var addServiceController = null;
  22. describe('App.AddServiceController', function() {
  23. beforeEach(function () {
  24. addServiceController = App.AddServiceController.create({});
  25. });
  26. describe('#installAdditionalClients', function() {
  27. var t = {
  28. additionalClients: {
  29. componentName: "TEZ_CLIENT",
  30. hostName: "hostName"
  31. },
  32. RequestInfo: {
  33. "context": Em.I18n.t('requestInfo.installHostComponent') + " hostName",
  34. "operation_level": {
  35. "level": "HOST_COMPONENT",
  36. "cluster_name": "tdk",
  37. "host_name": "hostName",
  38. "service_name": "TEZ"
  39. }
  40. },
  41. Body: {
  42. HostRoles: {
  43. state: 'INSTALLED'
  44. }
  45. }
  46. };
  47. beforeEach(function () {
  48. sinon.spy($, 'ajax');
  49. sinon.stub(App, 'get', function(k) {
  50. if ('clusterName' === k) return 'tdk';
  51. return Em.get(App, k);
  52. });
  53. });
  54. afterEach(function () {
  55. $.ajax.restore();
  56. App.get.restore();
  57. });
  58. it('send request to install client', function () {
  59. addServiceController.set("content.additionalClients", [t.additionalClients]);
  60. addServiceController.installAdditionalClients();
  61. expect($.ajax.calledOnce).to.equal(true);
  62. expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body);
  63. expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo);
  64. });
  65. });
  66. });