host_stack_version_test.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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: 'INIT',
  25. result: Em.I18n.t('hosts.host.stackVersions.status.init')
  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: '',
  41. result: Em.I18n.t('common.unknown')
  42. }
  43. ];
  44. afterEach(function () {
  45. App.HostStackVersion.find().clear();
  46. });
  47. testCases.forEach(function (test) {
  48. it('status is ' + test.status, function () {
  49. App.store.load(App.HostStackVersion, {
  50. id: 1,
  51. status: test.status
  52. });
  53. expect(App.HostStackVersion.find().objectAt(0).get('displayStatus')).to.equal(test.result);
  54. });
  55. }, this);
  56. });
  57. describe("#installEnabled", function () {
  58. var testCases = [
  59. {
  60. status: 'INIT',
  61. result: true
  62. },
  63. {
  64. status: 'INSTALLED',
  65. result: false
  66. },
  67. {
  68. status: 'INSTALLING',
  69. result: false
  70. },
  71. {
  72. status: 'INSTALL_FAILED',
  73. result: true
  74. },
  75. {
  76. status: '',
  77. result: false
  78. }
  79. ];
  80. afterEach(function () {
  81. App.HostStackVersion.find().clear();
  82. });
  83. testCases.forEach(function (test) {
  84. it('status is ' + test.status, function () {
  85. App.store.load(App.HostStackVersion, {
  86. id: 1,
  87. status: test.status
  88. });
  89. expect(App.HostStackVersion.find().objectAt(0).get('installEnabled')).to.equal(test.result);
  90. });
  91. }, this);
  92. });
  93. describe("#isCurrent", function () {
  94. afterEach(function () {
  95. App.HostStackVersion.find().clear();
  96. });
  97. it("status is CURRENT", function () {
  98. App.store.load(App.HostStackVersion, {
  99. id: 1,
  100. status: 'CURRENT'
  101. });
  102. expect(App.HostStackVersion.find(1).get('isCurrent')).to.be.true;
  103. });
  104. it("status is not CURRENT", function () {
  105. App.store.load(App.HostStackVersion, {
  106. id: 1,
  107. status: 'INSTALLED'
  108. });
  109. expect(App.HostStackVersion.find(1).get('isCurrent')).to.be.false;
  110. });
  111. });
  112. });