| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- import View from 'ckeditor5-ui/src/view';
- import LinkFormView from 'ckeditor5-link/src/ui/linkformview';
- describe( 'LinkFormView', () => {
- let view;
- beforeEach( () => {
- view = new LinkFormView( { t: () => {} } );
- view.init();
- } );
- describe( 'constructor()', () => {
- it( 'should create element from template', () => {
- expect( view.element.classList.contains( 'ck-link-form' ) ).to.true;
- } );
- it( 'should create child views', () => {
- expect( view.urlInputView ).to.be.instanceOf( View );
- expect( view.saveButtonView ).to.be.instanceOf( View );
- expect( view.cancelButtonView ).to.be.instanceOf( View );
- expect( view.unlinkButtonView ).to.be.instanceOf( View );
- expect( view._unboundChildren.get( 0 ) ).to.equal( view.urlInputView );
- expect( view._unboundChildren.get( 1 ) ).to.equal( view.saveButtonView );
- expect( view._unboundChildren.get( 2 ) ).to.equal( view.cancelButtonView );
- expect( view._unboundChildren.get( 3 ) ).to.equal( view.unlinkButtonView );
- } );
- it( 'should fire `cancel` event on cancelButtonView#execute', () => {
- const spy = sinon.spy();
- view.on( 'cancel', spy );
- view.cancelButtonView.fire( 'execute' );
- expect( spy.calledOnce ).to.true;
- } );
- it( 'should fire `unlink` event on unlinkButtonView#execute', () => {
- const spy = sinon.spy();
- view.on( 'unlink', spy );
- view.unlinkButtonView.fire( 'execute' );
- expect( spy.calledOnce ).to.true;
- } );
- describe( 'template', () => {
- it( 'has url input view', () => {
- expect( view.template.children.get( 0 ) ).to.equal( view.urlInputView );
- } );
- it( 'has form actions container', () => {
- expect( view.template.children.get( 1 ).attributes.class ).to.have.members( [ 'ck-link-form__actions' ] );
- } );
- it( 'has form action views', () => {
- const actions = view.template.children.get( 1 ).children;
- expect( actions.get( 0 ) ).to.equal( view.saveButtonView );
- expect( actions.get( 1 ) ).to.equal( view.cancelButtonView );
- expect( actions.get( 2 ) ).to.equal( view.unlinkButtonView );
- } );
- } );
- } );
- describe( 'DOM bindings', () => {
- describe( 'submit event', () => {
- it( 'should trigger submit event', () => {
- const spy = sinon.spy();
- view.on( 'submit', spy );
- view.element.dispatchEvent( new Event( 'submit' ) );
- expect( spy.calledOnce ).to.true;
- } );
- } );
- } );
- } );
|