step1_controller_test.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 testHelpers = require('test/helpers');
  20. function getController() {
  21. return App.KerberosWizardStep1Controller.create({});
  22. }
  23. describe('App.KerberosWizardStep1Controller', function() {
  24. var controller;
  25. beforeEach(function() {
  26. controller = getController();
  27. });
  28. describe("#selectedOption", function () {
  29. it("test", function() {
  30. controller.setProperties({
  31. options: [{value: 'item1'}],
  32. selectedItem: 'item1'
  33. });
  34. controller.propertyDidChange('selectedOption');
  35. expect(controller.get('selectedOption')).to.be.eql({value: 'item1'});
  36. });
  37. });
  38. describe("#loadStep()", function () {
  39. beforeEach(function() {
  40. controller.set('options', []);
  41. });
  42. it("enableIpa is true", function() {
  43. App.set('supports.enableIpa', true);
  44. controller.loadStep();
  45. expect(controller.get('selectedItem')).to.be.equal(Em.I18n.t('admin.kerberos.wizard.step1.option.kdc'));
  46. expect(controller.get('options')).to.not.be.empty;
  47. });
  48. it("enableIpa is false", function() {
  49. App.set('supports.enableIpa', false);
  50. controller.loadStep();
  51. expect(controller.get('selectedItem')).to.be.equal(Em.I18n.t('admin.kerberos.wizard.step1.option.kdc'));
  52. expect(controller.get('options')).to.be.empty;
  53. });
  54. });
  55. describe("#next()", function () {
  56. beforeEach(function() {
  57. sinon.stub(App.router, 'send');
  58. });
  59. afterEach(function() {
  60. App.router.send.restore();
  61. });
  62. it("App.router.send should be called", function() {
  63. controller.reopen({
  64. 'isSubmitDisabled': false
  65. });
  66. controller.next();
  67. expect(App.router.send.calledOnce).to.be.true;
  68. });
  69. it("App.router.send should not be called", function() {
  70. controller.reopen({
  71. 'isSubmitDisabled': true
  72. });
  73. controller.next();
  74. expect(App.router.send.called).to.be.false;
  75. });
  76. });
  77. });