component_test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 component = require('utils/component');
  20. require('models/host_component');
  21. require('models/stack_service_component');
  22. describe('utils/component', function(){
  23. describe('#loadStackServiceComponentModel()', function(){
  24. var data = {
  25. "items": [
  26. {
  27. "serviceComponents": [
  28. {
  29. "StackServiceComponents": {
  30. "component_category": "CLIENT",
  31. "component_name": "FALCON_CLIENT",
  32. "is_client": true,
  33. "is_master": false,
  34. "service_name": "FALCON",
  35. "stack_name": "HDP",
  36. "stack_version": "2.1"
  37. }
  38. },
  39. {
  40. "StackServiceComponents": {
  41. "component_category": "MASTER",
  42. "component_name": "FALCON_SERVER",
  43. "is_client": false,
  44. "is_master": true,
  45. "service_name": "FALCON",
  46. "stack_name": "HDP",
  47. "stack_version": "2.1"
  48. }
  49. }
  50. ]
  51. },
  52. {
  53. "serviceComponents": [
  54. {
  55. "StackServiceComponents": {
  56. "component_category": "SLAVE",
  57. "component_name": "GANGLIA_MONITOR",
  58. "is_client": false,
  59. "is_master": false,
  60. "service_name": "GANGLIA",
  61. "stack_name": "HDP",
  62. "stack_version": "2.1"
  63. }
  64. },
  65. {
  66. "StackServiceComponents": {
  67. "component_category": "MASTER",
  68. "component_name": "GANGLIA_SERVER",
  69. "is_client": false,
  70. "is_master": true,
  71. "service_name": "GANGLIA",
  72. "stack_name": "HDP",
  73. "stack_version": "2.1"
  74. }
  75. }
  76. ]
  77. }
  78. ]
  79. };
  80. afterEach(function(){
  81. App.StackServiceComponent.find().set('content', []);
  82. });
  83. it('should return 4 components', function(){
  84. expect(component.loadStackServiceComponentModel(data).items.length).to.eql(4);
  85. });
  86. it('should load data to StackServiceComponent model', function(){
  87. component.loadStackServiceComponentModel(data);
  88. expect(App.StackServiceComponent.find().get('content')).have.length(4);
  89. });
  90. });
  91. });