application_test.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. var testHelpers = require('test/helpers');
  21. function getController() {
  22. return App.ApplicationController.create();
  23. }
  24. describe('App.ApplicationController', function () {
  25. var applicationController = getController();
  26. App.TestAliases.testAsComputedAnd(getController(), 'isClusterDataLoaded', ['App.router.clusterController.isLoaded','App.router.loggedIn']);
  27. App.TestAliases.testAsComputedAnd(getController(), 'isExistingClusterDataLoaded', ['App.router.clusterInstallCompleted','isClusterDataLoaded']);
  28. describe('#showAboutPopup', function() {
  29. var dataToShowRes = {};
  30. beforeEach(function () {
  31. sinon.stub(App.ModalPopup, 'show', function(dataToShow){
  32. dataToShowRes = dataToShow;
  33. });
  34. });
  35. afterEach(function () {
  36. App.ModalPopup.show.restore();
  37. });
  38. it ('Should send correct data to popup', function() {
  39. applicationController.showAboutPopup();
  40. dataToShowRes = JSON.parse(JSON.stringify(dataToShowRes));
  41. expect(dataToShowRes).to.eql({
  42. "header": "About",
  43. "secondary": false
  44. });
  45. });
  46. });
  47. describe('#clusterName', function() {
  48. beforeEach(function () {
  49. sinon.stub(App.router, 'get').returns('cl1');
  50. });
  51. afterEach(function () {
  52. App.router.get.restore();
  53. });
  54. it ('Should return cluster name', function() {
  55. expect(applicationController.get('clusterName')).to.equal('cl1');
  56. });
  57. });
  58. describe('#startKeepAlivePoller', function() {
  59. it ('Should change run poller state', function() {
  60. applicationController.set('isPollerRunning', false);
  61. applicationController.startKeepAlivePoller();
  62. expect(applicationController.get('isPollerRunning')).to.be.true;
  63. });
  64. });
  65. describe('#goToAdminView', function() {
  66. var result;
  67. beforeEach(function () {
  68. sinon.stub(App.router, 'route', function(data) {
  69. result = data;
  70. return false;
  71. });
  72. });
  73. afterEach(function () {
  74. App.router.route.restore();
  75. });
  76. it ('Should call route once', function() {
  77. applicationController.goToAdminView();
  78. expect(result).to.be.equal('adminView');
  79. });
  80. });
  81. describe('#getStack', function() {
  82. it ('Should return send value', function() {
  83. var callback = {
  84. 'callback': true
  85. };
  86. applicationController.getStack(callback);
  87. var args = testHelpers.findAjaxRequest('name', 'router.login.clusters');
  88. expect(args[0]).to.exists;
  89. expect(args[0].callback.callback).to.be.true;
  90. });
  91. });
  92. });