linkformview.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: ui, form */
  6. import View from '/ckeditor5/ui/view.js';
  7. import LinkFormView from '/ckeditor5/link/ui/linkformview.js';
  8. describe( 'LinkFormView', () => {
  9. let view;
  10. beforeEach( () => {
  11. view = new LinkFormView();
  12. view.init();
  13. } );
  14. describe( 'constructor', () => {
  15. it( 'should create element from template', () => {
  16. expect( view.element.classList.contains( 'ck-link-form' ) ).to.true;
  17. } );
  18. it( 'should create child views', () => {
  19. expect( view.urlInputView ).to.be.instanceOf( View );
  20. expect( view.saveButtonView ).to.be.instanceOf( View );
  21. expect( view.cancelButtonView ).to.be.instanceOf( View );
  22. expect( view.unlinkButtonView ).to.be.instanceOf( View );
  23. } );
  24. describe( 'template', () => {
  25. it( 'has url input view', () => {
  26. expect( view.template.children.get( 0 ) ).to.equal( view.urlInputView );
  27. } );
  28. it( 'has form actions container', () => {
  29. expect( view.template.children.get( 1 ).attributes.class ).to.have.members( [ 'ck-link-form__actions' ] );
  30. } );
  31. it( 'has form action views', () => {
  32. const actions = view.template.children.get( 1 ).children;
  33. expect( actions.get( 0 ) ).to.equal( view.saveButtonView );
  34. expect( actions.get( 1 ) ).to.equal( view.cancelButtonView );
  35. expect( actions.get( 2 ) ).to.equal( view.unlinkButtonView );
  36. } );
  37. } );
  38. } );
  39. describe( 'DOM bindings', () => {
  40. describe( 'submit event', () => {
  41. it( 'should trigger submit event', () => {
  42. const spy = sinon.spy();
  43. view.on( 'submit', spy );
  44. view.element.dispatchEvent( new Event( 'submit' ) );
  45. expect( spy.calledOnce ).to.true;
  46. } );
  47. } );
  48. } );
  49. } );