step3_test.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/main/admin/security/add/step3');
  20. require('utils/polling');
  21. require('models/cluster_states');
  22. describe('App.MainAdminSecurityAddStep3Controller', function () {
  23. /**
  24. * Test object
  25. */
  26. var controller = App.MainAdminSecurityAddStep3Controller.create();
  27. describe('#moveToNextStage()', function () {
  28. controller.reopen({
  29. startStage: function(){},
  30. saveStages: function(){}
  31. });
  32. App.clusterStatus.reopen({
  33. setClusterStatus: function(){}
  34. });
  35. it('first stage is started', function(){
  36. controller.set('stages', [
  37. App.Poll.create({stage: 'stage1', isStarted: false, isCompleted: false}),
  38. App.Poll.create({stage: 'stage2', isStarted: false, isCompleted: false}),
  39. App.Poll.create({stage: 'stage3', isStarted: false, isCompleted: false})
  40. ]);
  41. controller.moveToNextStage();
  42. expect(controller.get('stages').findProperty('stage', 'stage1').get('isStarted')).to.equal(true);
  43. });
  44. it('second stage is started', function(){
  45. controller.set('stages', [
  46. App.Poll.create({stage: 'stage1', isStarted: true, isCompleted: true}),
  47. App.Poll.create({stage: 'stage2', isStarted: false, isCompleted: false}),
  48. App.Poll.create({stage: 'stage3', isStarted: false, isCompleted: false})
  49. ]);
  50. controller.moveToNextStage();
  51. expect(controller.get('stages').findProperty('stage', 'stage2').get('isStarted')).to.equal(true);
  52. });
  53. it('third stage is started', function(){
  54. controller.set('stages', [
  55. App.Poll.create({stage: 'stage1', isStarted: true, isCompleted: true}),
  56. App.Poll.create({stage: 'stage2', isStarted: true, isCompleted: true}),
  57. App.Poll.create({stage: 'stage3', isStarted: false, isCompleted: false})
  58. ]);
  59. controller.moveToNextStage();
  60. expect(controller.get('stages').findProperty('stage', 'stage3').get('isStarted')).to.equal(true);
  61. });
  62. });
  63. });