service_config_container_view_test.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/common/chart/pie');
  20. require('views/common/configs/services_config');
  21. describe('App.ServiceConfigContainerView', function () {
  22. var view;
  23. beforeEach(function () {
  24. view = App.ServiceConfigContainerView.create({
  25. filter: ''
  26. });
  27. });
  28. describe('#pushView', function () {
  29. it('shouldn\'t be launched before selectedService is set', function () {
  30. view.set('controller', {});
  31. view.pushView();
  32. expect(view.get('childViews')).to.be.empty;
  33. });
  34. });
  35. describe('#selectedServiceObserver', function () {
  36. it('should add a child view', function () {
  37. view.set('controller', Em.Object.create({
  38. selectedService: {
  39. configCategories: [],
  40. configs: []
  41. },
  42. isRecommendedLoaded: true
  43. }));
  44. expect(view.get('childViews')).to.have.length(1);
  45. });
  46. it('should set controller for the view', function () {
  47. view.set('controller', Em.Object.create({
  48. name: 'controller',
  49. selectedService: {
  50. configCategories: [],
  51. configs: []
  52. },
  53. isRecommendedLoaded: true
  54. }));
  55. expect(view.get('childViews.firstObject.controller.name')).to.equal('controller');
  56. });
  57. it('should add config categories', function () {
  58. view.set('controller', Em.Object.create({
  59. selectedService: {
  60. configCategories: [Em.Object.create(), Em.Object.create()],
  61. configs: []
  62. },
  63. isRecommendedLoaded: true
  64. }));
  65. expect(view.get('childViews.firstObject.serviceConfigsByCategoryView.childViews')).to.have.length(2);
  66. });
  67. });
  68. });