overriddenProperty_view_test.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/configs/overriddenProperty_view');
  20. describe('App.ServiceConfigView.SCPOverriddenRowsView', function () {
  21. var view = App.ServiceConfigView.SCPOverriddenRowsView.create();
  22. describe('#didInsertElement', function () {
  23. beforeEach(function () {
  24. sinon.spy(view, 'setSwitchText');
  25. sinon.stub(App, 'tooltip', Em.K);
  26. });
  27. afterEach(function () {
  28. view.setSwitchText.restore();
  29. App.tooltip.restore();
  30. });
  31. it('setSwitchLinks method should be executed', function () {
  32. view.didInsertElement();
  33. expect(view.setSwitchText.calledOnce).to.be.true;
  34. });
  35. });
  36. describe('#setSwitchText', function () {
  37. view = App.ServiceConfigView.SCPOverriddenRowsView.create({
  38. serviceConfigProperty: {
  39. overrides: [
  40. Em.Object.create({
  41. group: Em.Object.create({
  42. displayName: 'hcg',
  43. switchGroupTextShort: 'short',
  44. switchGroupTextFull: 'full'
  45. })
  46. })
  47. ]
  48. }
  49. });
  50. beforeEach(function () {
  51. sinon.stub(App, 'tooltip', Em.K);
  52. });
  53. afterEach(function () {
  54. App.tooltip.restore();
  55. });
  56. it('should not modify overrides', function () {
  57. view.set('isDefaultGroupSelected', false);
  58. expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextShort')).to.equal('short');
  59. expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextFull')).to.equal('full');
  60. });
  61. it('should set switchGroupTextShort and switchGroupTextFull', function () {
  62. view.set('isDefaultGroupSelected', true);
  63. expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextShort')).to.equal(Em.I18n.t('services.service.config_groups.switchGroupTextShort').format('hcg'));
  64. expect(view.get('serviceConfigProperty.overrides.firstObject.group.switchGroupTextFull')).to.equal(Em.I18n.t('services.service.config_groups.switchGroupTextFull').format('hcg'));
  65. });
  66. });
  67. });