host_stack_version_test.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. });