manage_alert_groups_view_test.js 2.9 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 view;
  20. function getView() {
  21. return App.MainAlertsManageAlertGroupView.create({
  22. controller: Em.Object.create()
  23. });
  24. }
  25. describe('App.MainAlertsManageAlertGroupView', function () {
  26. beforeEach(function () {
  27. view = getView();
  28. });
  29. it('#buttonObserver', function () {
  30. Em.A([
  31. {
  32. p: {
  33. isRemoveButtonDisabled: false,
  34. isRenameButtonDisabled: false,
  35. isDuplicateButtonDisabled: true
  36. },
  37. selectedAlertGroup: {default: true},
  38. m: 'selected alert group is default',
  39. e: {
  40. isRemoveButtonDisabled: true,
  41. isRenameButtonDisabled: true,
  42. isDuplicateButtonDisabled: false
  43. }
  44. },
  45. {
  46. p: {
  47. isRemoveButtonDisabled: true,
  48. isRenameButtonDisabled: true,
  49. isDuplicateButtonDisabled: true
  50. },
  51. selectedAlertGroup: {default: false},
  52. m: 'selected alert group is not default',
  53. e: {
  54. isRemoveButtonDisabled: false,
  55. isRenameButtonDisabled: false,
  56. isDuplicateButtonDisabled: false
  57. }
  58. },
  59. {
  60. p: {
  61. isRemoveButtonDisabled: true,
  62. isRenameButtonDisabled: true,
  63. isDuplicateButtonDisabled: true
  64. },
  65. selectedAlertGroup: null,
  66. m: 'not one alert group is selected',
  67. e: {
  68. isRemoveButtonDisabled: false,
  69. isRenameButtonDisabled: false,
  70. isDuplicateButtonDisabled: false
  71. }
  72. }
  73. ]).forEach(function (test) {
  74. it(test.m, function () {
  75. Em.keys(test.p).forEach(function (k) {
  76. view.set(k, test.p[k]);
  77. });
  78. view.set('controller.selectedAlertGroup', test.selectedAlertGroup);
  79. Em.keys(test.e).forEach(function (k) {
  80. expect(view.get(k)).to.equal(test.e[k]);
  81. });
  82. });
  83. });
  84. });
  85. App.TestAliases.testAsComputedIfThenElse(getView(), 'removeButtonTooltip', 'controller.isRemoveButtonDisabled', Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButtonDisabled'), Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButton'))
  86. });