step1_controller_test.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. App = require('app');
  19. require('controllers/main/service/widgets/create/step1_controller');
  20. describe('App.WidgetWizardStep1Controller', function () {
  21. var controller = App.WidgetWizardStep1Controller.create();
  22. describe("#isSubmitDisabled", function() {
  23. it("disabled", function() {
  24. controller.set('widgetType', '');
  25. controller.propertyDidChange('isSubmitDisabled');
  26. expect(controller.get('isSubmitDisabled')).to.be.true;
  27. });
  28. it("enabled", function() {
  29. controller.set('widgetType', 'w1');
  30. controller.propertyDidChange('isSubmitDisabled');
  31. expect(controller.get('isSubmitDisabled')).to.be.false;
  32. });
  33. });
  34. describe("#chooseOption()", function () {
  35. before(function () {
  36. sinon.stub(controller, 'next');
  37. });
  38. after(function () {
  39. controller.next.restore();
  40. });
  41. it("", function () {
  42. controller.chooseOption({context: 'type1'});
  43. expect(controller.get('widgetType')).to.equal('type1');
  44. expect(controller.next.calledOnce).to.be.true;
  45. });
  46. });
  47. describe("#loadStep()", function () {
  48. before(function () {
  49. sinon.stub(controller, 'clearStep');
  50. });
  51. after(function () {
  52. controller.clearStep.restore();
  53. });
  54. it("", function () {
  55. controller.loadStep();
  56. expect(controller.clearStep.calledOnce).to.be.true;
  57. });
  58. });
  59. describe("#clearStep()", function () {
  60. it("", function () {
  61. controller.clearStep();
  62. expect(controller.get('widgetType')).to.be.empty;
  63. });
  64. });
  65. describe("#next()", function () {
  66. before(function () {
  67. sinon.stub(App.router, 'send');
  68. });
  69. after(function () {
  70. App.router.send.restore();
  71. });
  72. it("", function () {
  73. controller.next();
  74. expect(App.router.send.calledWith('next')).to.be.true;
  75. });
  76. });
  77. });