host_stack_version_test.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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/host_stack_version');
  20. describe('App.HostStackVersion', function () {
  21. describe("#displayStatus", function () {
  22. var testCases = [
  23. {
  24. status: 'OUT_OF_SYNC',
  25. result: Em.I18n.t('hosts.host.stackVersions.status.out_of_sync')
  26. },
  27. {
  28. status: 'INSTALLED',
  29. result: Em.I18n.t('hosts.host.stackVersions.status.installed')
  30. },
  31. {
  32. status: 'INSTALLING',
  33. result: Em.I18n.t('hosts.host.stackVersions.status.installing')
  34. },
  35. {
  36. status: 'INSTALL_FAILED',
  37. result: Em.I18n.t('hosts.host.stackVersions.status.install_failed')
  38. },
  39. {
  40. status: 'UPGRADE_FAILED',
  41. result: Em.I18n.t('hosts.host.stackVersions.status.upgrade_failed')
  42. },
  43. {
  44. status: 'UPGRADING',
  45. result: Em.I18n.t('hosts.host.stackVersions.status.upgrading')
  46. },
  47. {
  48. status: 'CURRENT',
  49. result: Em.I18n.t('hosts.host.stackVersions.status.current')
  50. },
  51. {
  52. status: 'ANY',
  53. result: 'Any'
  54. }
  55. ];
  56. afterEach(function () {
  57. App.HostStackVersion.find().clear();
  58. });
  59. testCases.forEach(function (test) {
  60. it('status is ' + test.status, function () {
  61. App.store.load(App.HostStackVersion, {
  62. id: 1,
  63. status: test.status
  64. });
  65. expect(App.HostStackVersion.find().objectAt(0).get('displayStatus')).to.equal(test.result);
  66. });
  67. }, this);
  68. });
  69. describe("#installEnabled", function () {
  70. var testCases = [
  71. {
  72. status: 'OUT_OF_SYNC',
  73. result: true
  74. },
  75. {
  76. status: 'INSTALLED',
  77. result: false
  78. },
  79. {
  80. status: 'INSTALLING',
  81. result: false
  82. },
  83. {
  84. status: 'INSTALL_FAILED',
  85. result: true
  86. },
  87. {
  88. status: '',
  89. result: false
  90. }
  91. ];
  92. afterEach(function () {
  93. App.HostStackVersion.find().clear();
  94. });
  95. testCases.forEach(function (test) {
  96. it('status is ' + test.status, function () {
  97. App.store.load(App.HostStackVersion, {
  98. id: 1,
  99. status: test.status
  100. });
  101. expect(App.HostStackVersion.find().objectAt(0).get('installEnabled')).to.equal(test.result);
  102. });
  103. }, this);
  104. });
  105. describe("#isCurrent", function () {
  106. afterEach(function () {
  107. App.HostStackVersion.find().clear();
  108. });
  109. it("status is CURRENT", function () {
  110. App.store.load(App.HostStackVersion, {
  111. id: 1,
  112. status: 'CURRENT'
  113. });
  114. expect(App.HostStackVersion.find(1).get('isCurrent')).to.be.true;
  115. });
  116. it("status is not CURRENT", function () {
  117. App.store.load(App.HostStackVersion, {
  118. id: 1,
  119. status: 'INSTALLED'
  120. });
  121. expect(App.HostStackVersion.find(1).get('isCurrent')).to.be.false;
  122. });
  123. });
  124. });