hosts_test.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/hosts');
  20. var hostInfo,
  21. statusCases = [
  22. {
  23. status: 'REGISTERED',
  24. bootStatusForDisplay: 'Success',
  25. bootBarColor: 'progress-success',
  26. bootStatusColor: 'text-success',
  27. isBootDone: true
  28. },
  29. {
  30. status: 'FAILED',
  31. bootStatusForDisplay: 'Failed',
  32. bootBarColor: 'progress-danger',
  33. bootStatusColor: 'text-error',
  34. isBootDone: true
  35. },
  36. {
  37. status: 'PENDING',
  38. bootStatusForDisplay: 'Preparing',
  39. bootBarColor: 'progress-info',
  40. bootStatusColor: 'text-info',
  41. isBootDone: false
  42. },
  43. {
  44. status: 'RUNNING',
  45. bootStatusForDisplay: 'Installing',
  46. bootBarColor: 'progress-info',
  47. bootStatusColor: 'text-info',
  48. isBootDone: false
  49. },
  50. {
  51. status: 'DONE',
  52. bootStatusForDisplay: 'Registering',
  53. bootBarColor: 'progress-info',
  54. bootStatusColor: 'text-info',
  55. isBootDone: false
  56. },
  57. {
  58. status: 'REGISTERING',
  59. bootStatusForDisplay: 'Registering',
  60. bootBarColor: 'progress-info',
  61. bootStatusColor: 'text-info',
  62. isBootDone: false
  63. }
  64. ],
  65. tests = ['bootStatusForDisplay', 'bootBarColor', 'bootStatusColor', 'isBootDone'];
  66. describe('App.HostInfo', function () {
  67. beforeEach(function () {
  68. hostInfo = App.HostInfo.create();
  69. });
  70. tests.forEach(function (property) {
  71. describe('#' + property, function () {
  72. statusCases.forEach(function (testCase) {
  73. it('should be ' + testCase[property], function () {
  74. hostInfo.set('bootStatus', testCase.status);
  75. expect(hostInfo.get(property)).to.equal(testCase[property]);
  76. });
  77. });
  78. });
  79. });
  80. });