service_config_container_view_test.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. }));
  43. expect(view.get('childViews')).to.have.length(1);
  44. });
  45. it('should set controller for the view', function () {
  46. view.set('controller', Em.Object.create({
  47. name: 'controller',
  48. selectedService: {
  49. configCategories: [],
  50. configs: []
  51. }
  52. }));
  53. expect(view.get('childViews.firstObject.controller.name')).to.equal('controller');
  54. });
  55. it('should add config categories', function () {
  56. view.set('controller', Em.Object.create({
  57. selectedService: {
  58. configCategories: [Em.Object.create(), Em.Object.create()],
  59. configs: []
  60. }
  61. }));
  62. expect(view.get('childViews.firstObject.serviceConfigsByCategoryView.childViews')).to.have.length(2);
  63. });
  64. });
  65. });