client_component_test.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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('models/client_component');
  20. describe('App.ClientComponent', function () {
  21. var clientComponent;
  22. beforeEach(function () {
  23. clientComponent = App.ClientComponent.createRecord();
  24. });
  25. describe('#allowToDelete', function () {
  26. var cases = [
  27. {
  28. statesCounts: {
  29. installedCount: 1,
  30. installFailedCount: 2,
  31. initCount: 3,
  32. unknownCount: 4,
  33. totalCount: 10
  34. },
  35. allowToDelete: true,
  36. title: 'delete allowed'
  37. },
  38. {
  39. statesCounts: {
  40. installedCount: 1,
  41. installFailedCount: 2,
  42. initCount: 3,
  43. unknownCount: 4,
  44. totalCount: 11
  45. },
  46. allowToDelete: false,
  47. title: 'delete not allowed'
  48. }
  49. ];
  50. cases.forEach(function (item) {
  51. it(item.title, function () {
  52. clientComponent.setProperties(item.statesCounts);
  53. expect(clientComponent.get('allowToDelete')).to.equal(item.allowToDelete);
  54. });
  55. });
  56. });
  57. describe('#summaryLabelClassName', function () {
  58. it('should use lower case of component name', function () {
  59. clientComponent.set('componentName', 'ZOOKEEPER_CLIENT');
  60. expect(clientComponent.get('summaryLabelClassName')).to.equal('label_for_zookeeper_client');
  61. });
  62. });
  63. describe('#summaryValueClassName', function () {
  64. it('should use lower case of component name', function () {
  65. clientComponent.set('componentName', 'ZOOKEEPER_CLIENT');
  66. expect(clientComponent.get('summaryValueClassName')).to.equal('value_for_zookeeper_client');
  67. });
  68. });
  69. describe('#displayNamePluralized', function () {
  70. var cases = [
  71. {
  72. installedCount: 1,
  73. displayNamePluralized: 'Zookeeper Client',
  74. title: 'singular'
  75. },
  76. {
  77. installedCount: 2,
  78. displayNamePluralized: 'Zookeeper Clients',
  79. title: 'plural'
  80. }
  81. ];
  82. cases.forEach(function (item) {
  83. it(item.title, function () {
  84. clientComponent.setProperties({
  85. displayName: 'Zookeeper Client',
  86. installedCount: item.installedCount
  87. });
  88. expect(clientComponent.get('displayNamePluralized')).to.equal(item.displayNamePluralized);
  89. });
  90. });
  91. });
  92. });