manage_config_groups_controller_test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 c;
  20. describe('App.ManageConfigGroupsController', function() {
  21. var controller = App.ManageConfigGroupsController.create({});
  22. beforeEach(function() {
  23. c = App.ManageConfigGroupsController.create({});
  24. });
  25. var manageConfigGroupsController = App.ManageConfigGroupsController.create({});
  26. describe('#addConfigGroup', function() {
  27. beforeEach(function() {
  28. manageConfigGroupsController.addConfigGroup();
  29. });
  30. describe("#validate", function() {
  31. it("should display no warning if user inputs valid characters into group name", function() {
  32. manageConfigGroupsController.addGroupPopup.set('configGroupName', 'hello');
  33. expect(manageConfigGroupsController.addGroupPopup.warningMessage).to.be.empty;
  34. });
  35. it("should display warning if user inputs invalid characters into group name", function() {
  36. manageConfigGroupsController.addGroupPopup.set('configGroupName', '/{"!@#$%');
  37. expect(manageConfigGroupsController.addGroupPopup.warningMessage).to.equal('Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.');
  38. });
  39. });
  40. });
  41. describe('#renameConfigGroup', function() {
  42. beforeEach(function() {
  43. var configGroup = Ember.Object.create ({
  44. name: 'name',
  45. description: 'description'
  46. });
  47. manageConfigGroupsController.set('selectedConfigGroup', configGroup);
  48. manageConfigGroupsController.renameConfigGroup();
  49. });
  50. describe("#validate", function() {
  51. it("should display no warning if user inputs valid characters into group name", function() {
  52. manageConfigGroupsController.renameGroupPopup.set('configGroupName', 'hello');
  53. expect(manageConfigGroupsController.renameGroupPopup.warningMessage).to.be.empty;
  54. });
  55. it("should display warning if user inputs invalid characters into group name", function() {
  56. manageConfigGroupsController.renameGroupPopup.set('configGroupName', '/{"!@#$%');
  57. expect(manageConfigGroupsController.renameGroupPopup.warningMessage).to.equal('Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.');
  58. });
  59. });
  60. });
  61. describe('#addHostsCallback', function() {
  62. beforeEach(function() {
  63. c.reopen({
  64. selectedConfigGroup: Em.Object.create({
  65. hosts: ['h1'],
  66. parentConfigGroup: Em.Object.create({
  67. hosts: ['h2', 'h3']
  68. })
  69. })
  70. });
  71. });
  72. it('should set hosts to selectedConfigGroup and remove them form default group', function () {
  73. c.addHostsCallback(['h2', 'h3']);
  74. expect(c.get('selectedConfigGroup.hosts')).to.include.members(['h1','h2','h3']);
  75. expect(c.get('selectedConfigGroup.parentConfigGroup.hosts').toArray()).to.be.empty;
  76. });
  77. });
  78. });