step3_test.js 3.5 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 Ember = require('ember');
  19. var App = require('app');
  20. require('models/hosts');
  21. require('controllers/installer/step3_controller');
  22. describe('App.InstallerStep3Controller', function () {
  23. //var controller = App.InstallerStep3Controller.create();
  24. describe('#parseHostInfo', function () {
  25. var controller = App.InstallerStep3Controller.create();
  26. it('should return true if there is no host with pending status in the data provided by REST bootstrap call.It should also update the status on the client side', function () {
  27. var hostFrmServer = [
  28. {
  29. name: '192.168.1.1',
  30. status: 'error'
  31. },
  32. {
  33. name: '192.168.1.2',
  34. status: 'success'
  35. },
  36. {
  37. name: '192.168.1.3',
  38. status: 'error'
  39. },
  40. {
  41. name: '192.168.1.4',
  42. status: 'success'
  43. }
  44. ];
  45. controller.content.pushObject(App.HostInfo.create({
  46. name: '192.168.1.1',
  47. status: 'error'
  48. }));
  49. controller.content.pushObject(App.HostInfo.create({
  50. name: '192.168.1.2',
  51. status: 'success'
  52. }));
  53. controller.content.pushObject(App.HostInfo.create({
  54. name: '192.168.1.3',
  55. status: 'pending' //status should be overriden to 'error' after the parseHostInfo call
  56. }));
  57. controller.content.pushObject(App.HostInfo.create({
  58. name: '192.168.1.4',
  59. status: 'success'
  60. }));
  61. var result = controller.parseHostInfo(hostFrmServer, controller.content);
  62. var host = controller.content.findProperty('name', '192.168.1.3');
  63. expect(result).to.equal(true);
  64. expect(host.status).to.equal('error');
  65. })
  66. })
  67. describe('#onAllChecked', function () {
  68. var controller = App.InstallerStep3Controller.create();
  69. it('should set all hosts to true on checking a global checkbox', function () {
  70. controller.content.pushObject(App.HostInfo.create({
  71. name: '192.168.1.1',
  72. status: 'error',
  73. isChecked: false
  74. }));
  75. controller.content.pushObject(App.HostInfo.create({
  76. name: '192.168.1.2',
  77. status: 'success',
  78. isChecked: false
  79. }));
  80. controller.content.pushObject(App.HostInfo.create({
  81. name: '192.168.1.3',
  82. status: 'pending', //status should be overriden to 'error' after the parseHostInfo call
  83. isChecked: true
  84. }));
  85. controller.content.pushObject(App.HostInfo.create({
  86. name: '192.168.1.4',
  87. status: 'success',
  88. isChecked: false
  89. }));
  90. controller.onAllChecked();
  91. controller.content.forEach(function (hostName) {
  92. var result = hostName.isChecked;
  93. expect(result).to.equal(true);
  94. });
  95. })
  96. })
  97. })