service_config_test.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/configs/objects/service_config');
  20. var serviceConfig,
  21. configs = [
  22. App.ServiceConfigProperty.create({
  23. 'name': 'p1',
  24. 'isVisible': true,
  25. 'hiddenBySection': false,
  26. 'hiddenBySubSection': false,
  27. 'isRequiredByAgent': true,
  28. 'isValid': true,
  29. 'isValidOverride': true
  30. }),
  31. App.ServiceConfigProperty.create({
  32. 'name': 'p2',
  33. 'isVisible': false,
  34. 'hiddenBySection': false,
  35. 'hiddenBySubSection': false,
  36. 'isRequiredByAgent': true,
  37. 'isValid': true,
  38. 'isValidOverride': true
  39. }),
  40. App.ServiceConfigProperty.create({
  41. 'name': 'p3',
  42. 'isVisible': true,
  43. 'hiddenBySection': true,
  44. 'hiddenBySubSection': true,
  45. 'isRequiredByAgent': true,
  46. 'isValid': true,
  47. 'isValidOverride': true
  48. }),
  49. App.ServiceConfigProperty.create({
  50. 'name': 'p4',
  51. 'isVisible': true,
  52. 'hiddenBySection': false,
  53. 'hiddenBySubSection': false,
  54. 'isRequiredByAgent': true,
  55. 'isValid': false,
  56. 'isValidOverride': true
  57. }),
  58. App.ServiceConfigProperty.create({
  59. 'name': 'p5',
  60. 'isVisible': true,
  61. 'hiddenBySection': false,
  62. 'hiddenBySubSection': false,
  63. 'isRequiredByAgent': true,
  64. 'isValid': true,
  65. 'isValidOverride': false
  66. }),
  67. App.ServiceConfigProperty.create({
  68. 'name': 'p6',
  69. 'isVisible': true,
  70. 'hiddenBySection': false,
  71. 'hiddenBySubSection': false,
  72. 'isRequiredByAgent': false,
  73. 'isRequired': false,
  74. 'isValid': true,
  75. 'isValidOverride': false
  76. }),
  77. App.ServiceConfigProperty.create({
  78. 'name': 'p7',
  79. 'isVisible': true,
  80. 'hiddenBySection': false,
  81. 'hiddenBySubSection': false,
  82. 'isRequiredByAgent': false,
  83. 'isValid': true,
  84. 'isRequired': true,
  85. 'isValidOverride': false
  86. })
  87. ];
  88. describe('App.ServiceConfig', function () {
  89. beforeEach(function () {
  90. serviceConfig = App.ServiceConfig.create({
  91. configs: configs
  92. });
  93. });
  94. describe('#activeProperties', function() {
  95. it('returns collection of properties that should be shown', function() {
  96. expect(serviceConfig.get('activeProperties').mapProperty('name')).to.be.eql(['p1','p4','p5','p7']);
  97. });
  98. });
  99. describe('#configsWithErrors', function() {
  100. it('returns collection of properties with errors', function() {
  101. expect(serviceConfig.get('configsWithErrors').mapProperty('name')).to.be.eql(['p4', 'p5', 'p7']);
  102. });
  103. });
  104. describe('#errorCount', function() {
  105. it('returns collection of properties with errors', function() {
  106. serviceConfig.reopen({
  107. configsWithErrors: [{}, {}]
  108. });
  109. expect(serviceConfig.get('errorCount')).to.equal(2);
  110. });
  111. });
  112. });