config_widget_view_test.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. var view;
  20. describe('App.ConfigWidgetView', function () {
  21. beforeEach(function () {
  22. view = App.ConfigWidgetView.create({
  23. initPopover: Em.K,
  24. config: Em.Object.create({
  25. isOriginalSCP: false,
  26. isPropertyOverridable: false,
  27. cantBeUndone: false,
  28. isNotDefaultValue: false
  29. })
  30. });
  31. });
  32. describe('#undoAllowed', function () {
  33. Em.A([
  34. {
  35. cfg: {
  36. cantBeUndone: false,
  37. isNotDefaultValue: false
  38. },
  39. e: false
  40. },
  41. {
  42. cfg: {
  43. cantBeUndone: true,
  44. isNotDefaultValue: false
  45. },
  46. e: false
  47. },
  48. {
  49. cfg: {
  50. cantBeUndone: false,
  51. isNotDefaultValue: true
  52. },
  53. e: true
  54. },
  55. {
  56. cfg: {
  57. cantBeUndone: true,
  58. isNotDefaultValue: true
  59. },
  60. e: false
  61. }
  62. ]).forEach(function (test, index) {
  63. it('test #' + index, function () {
  64. view.get('config').setProperties(test.cfg);
  65. expect(view.get('undoAllowed')).to.equal(test.e);
  66. });
  67. });
  68. });
  69. describe('#overrideAllowed', function () {
  70. Em.A([
  71. {
  72. cfg: {
  73. isOriginalSCP: false,
  74. isPropertyOverridable: false,
  75. isComparison: false
  76. },
  77. e: false
  78. },
  79. {
  80. cfg: {
  81. isOriginalSCP: true,
  82. isPropertyOverridable: false,
  83. isComparison: false
  84. },
  85. e: false
  86. },
  87. {
  88. cfg: {
  89. isOriginalSCP: false,
  90. isPropertyOverridable: true,
  91. isComparison: false
  92. },
  93. e: false
  94. },
  95. {
  96. cfg: {
  97. isOriginalSCP: true,
  98. isPropertyOverridable: true,
  99. isComparison: false
  100. },
  101. e: true
  102. },
  103. {
  104. cfg: {
  105. isOriginalSCP: false,
  106. isPropertyOverridable: false,
  107. isComparison: true
  108. },
  109. e: false
  110. },
  111. {
  112. cfg: {
  113. isOriginalSCP: true,
  114. isPropertyOverridable: false,
  115. isComparison: true
  116. },
  117. e: false
  118. },
  119. {
  120. cfg: {
  121. isOriginalSCP: false,
  122. isPropertyOverridable: true,
  123. isComparison: true
  124. },
  125. e: false
  126. },
  127. {
  128. cfg: {
  129. isOriginalSCP: true,
  130. isPropertyOverridable: true,
  131. isComparison: true
  132. },
  133. e: false
  134. }
  135. ]).forEach(function (test, index) {
  136. it('test #' + index, function () {
  137. view.get('config').setProperties(test.cfg);
  138. expect(view.get('overrideAllowed')).to.equal(test.e);
  139. });
  140. });
  141. });
  142. });