version_view_test.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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('views/main/admin/stack_upgrade/upgrade_wizard_view');
  20. describe('App.mainAdminStackVersionsView', function () {
  21. var view = App.MainAdminStackVersionsView.create({
  22. controller: {
  23. currentVersion: {
  24. repository_version: "2.2.1.0"
  25. }
  26. }
  27. });
  28. describe("#filterBy()", function () {
  29. var versions = [
  30. Em.Object.create({
  31. status: "INIT"
  32. }),
  33. Em.Object.create({
  34. status: "INSTALLING"
  35. }),
  36. Em.Object.create({
  37. status: "INSTALLED",
  38. repositoryVersion: "2.2.0.1"
  39. }),
  40. Em.Object.create({
  41. status: "INSTALLED",
  42. repositoryVersion: "2.2.2.1"
  43. }),
  44. Em.Object.create({
  45. status: "INSTALL_FAILED"
  46. }),
  47. Em.Object.create({
  48. status: "OUT_OF_SYNC"
  49. }),
  50. Em.Object.create({
  51. status: "UPGRADING"
  52. }),
  53. Em.Object.create({
  54. status: "UPGRADE_FAILED"
  55. }),
  56. Em.Object.create({
  57. status: "CURRENT"
  58. })
  59. ];
  60. var tets = [
  61. {
  62. filter: Em.Object.create({}),
  63. filteredVersions: [
  64. Em.Object.create({
  65. status: "INIT"
  66. }),
  67. Em.Object.create({
  68. status: "INSTALLING"
  69. }),
  70. Em.Object.create({
  71. status: "INSTALLED",
  72. repositoryVersion: "2.2.0.1"
  73. }),
  74. Em.Object.create({
  75. status: "INSTALLED",
  76. repositoryVersion: "2.2.2.1"
  77. }),
  78. Em.Object.create({
  79. status: "INSTALL_FAILED"
  80. }),
  81. Em.Object.create({
  82. status: "OUT_OF_SYNC"
  83. }),
  84. Em.Object.create({
  85. status: "UPGRADING"
  86. }),
  87. Em.Object.create({
  88. status: "UPGRADE_FAILED"
  89. }),
  90. Em.Object.create({
  91. status: "CURRENT"
  92. })
  93. ]
  94. },
  95. {
  96. filter: Em.Object.create({
  97. statuses: ["INIT", "INSTALLING", "INSTALL_FAILED", "OUT_OF_SYNC"]
  98. }),
  99. filteredVersions: [
  100. Em.Object.create({
  101. status: "INIT"
  102. }),
  103. Em.Object.create({
  104. status: "INSTALLING"
  105. }),
  106. Em.Object.create({
  107. status: "INSTALL_FAILED"
  108. }),
  109. Em.Object.create({
  110. status: "OUT_OF_SYNC"
  111. })
  112. ]
  113. },
  114. {
  115. filter: Em.Object.create({
  116. statuses: ["INSTALLED"]
  117. }),
  118. filteredVersions: [
  119. Em.Object.create({
  120. status: "INSTALLED",
  121. repositoryVersion: "2.2.2.1"
  122. })
  123. ]
  124. },
  125. {
  126. filter: Em.Object.create({
  127. statuses: ["CURRENT"]
  128. }),
  129. filteredVersions: [
  130. Em.Object.create({
  131. status: "CURRENT"
  132. })
  133. ]
  134. }
  135. ].forEach(function(t) {
  136. var msg = t.filter.get('statuses') ? t.filter.get('statuses').toString() : "All";
  137. it("filter By " + msg, function () {
  138. expect(view.filterBy(versions, t.filter)).to.eql(t.filteredVersions);
  139. });
  140. });
  141. });
  142. });