definitions_details_controller_test.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 controller;
  20. describe('App.MainAlertDefinitionDetailsController', function () {
  21. beforeEach(function () {
  22. controller = App.MainAlertDefinitionDetailsController.create({
  23. content: Em.Object.create({
  24. description: 'description',
  25. label: 'label'
  26. })
  27. });
  28. });
  29. describe('#labelValidation()', function () {
  30. it('should set editing.label.isError to true', function () {
  31. controller.set('editing.label.value', ' ');
  32. expect(controller.get('editing.label.isError')).to.be.true;
  33. });
  34. });
  35. describe('#descriptionValidation()', function () {
  36. it('should set editing.description.isError to true', function () {
  37. controller.set('editing.description.value', ' ');
  38. expect(controller.get('editing.description.isError')).to.be.true;
  39. });
  40. });
  41. describe('#edit()', function () {
  42. it('should change value of value, originalValue and isEditing properties', function () {
  43. controller.set('editing.label.value', 'test');
  44. controller.set('editing.label.originalValue', 'test');
  45. controller.set('editing.label.isEditing', false);
  46. controller.edit({context:controller.get('editing.label')});
  47. expect(controller.get('editing.label.value')).to.equal('label');
  48. expect(controller.get('editing.label.originalValue')).to.equal('label');
  49. expect(controller.get('editing.label.isEditing')).to.be.true;
  50. });
  51. });
  52. describe('#saveEdit()', function () {
  53. it('should change values of content.label and isEditing properties', function () {
  54. controller.set('editing.label.value', 'test');
  55. controller.set('editing.label.isEditing', true);
  56. controller.saveEdit({context:controller.get('editing.label')});
  57. expect(controller.get('content.label')).to.equal('test');
  58. expect(controller.get('editing.label.isEditing')).to.be.false;
  59. });
  60. });
  61. describe('#toggleState()', function () {
  62. it('should call App.ajax.send function', function () {
  63. sinon.spy(App.ajax, 'send');
  64. controller.toggleState();
  65. expect(App.ajax.send.calledOnce).to.be.true;
  66. App.ajax.send.restore();
  67. });
  68. });
  69. });