step1_test.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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('controllers/installer/step1_controller');
  20. describe('App.InstallerStep1Controller', function () {
  21. describe('#validateStep1()', function () {
  22. it('should return false and sets invalidClusterName to true if cluster name is empty', function () {
  23. var controller = App.InstallerStep1Controller.create();
  24. controller.set('clusterName', '');
  25. expect(controller.validateStep1()).to.equal(false);
  26. expect(controller.get('invalidClusterName')).to.equal(true);
  27. })
  28. it('should return false and sets invalidClusterName to true if cluster name has whitespaces', function () {
  29. var controller = App.InstallerStep1Controller.create();
  30. controller.set('clusterName', 'My Cluster');
  31. expect(controller.validateStep1()).to.equal(false);
  32. expect(controller.get('invalidClusterName')).to.equal(true);
  33. })
  34. it('should return false and sets invalidClusterName to true if cluster name has special characters', function () {
  35. var controller = App.InstallerStep1Controller.create();
  36. controller.set('clusterName', 'my-cluster');
  37. expect(controller.validateStep1()).to.equal(false);
  38. expect(controller.get('invalidClusterName')).to.equal(true);
  39. })
  40. it('should return true, sets invalidClusterName to false if cluster name is valid', function () {
  41. var controller = App.InstallerStep1Controller.create();
  42. var clusterName = 'mycluster1';
  43. controller.set('clusterName', clusterName);
  44. expect(controller.validateStep1()).to.equal(true);
  45. expect(controller.get('invalidClusterName')).to.equal(false);
  46. })
  47. })
  48. })