|
|
@@ -246,7 +246,7 @@ describe( 'LinkUI', () => {
|
|
|
expect( formView.urlInputView.inputView.element.value ).to.equal( '' );
|
|
|
} );
|
|
|
|
|
|
- describe( 'response to view#change', () => {
|
|
|
+ describe( 'response to ui#update', () => {
|
|
|
let view, viewDocument;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
@@ -254,17 +254,17 @@ describe( 'LinkUI', () => {
|
|
|
viewDocument = view.document;
|
|
|
} );
|
|
|
|
|
|
- it( 'should not duplicate #change listeners', () => {
|
|
|
+ it( 'should not duplicate #update listeners', () => {
|
|
|
setModelData( editor.model, '<paragraph>f[]oo</paragraph>' );
|
|
|
|
|
|
const spy = testUtils.sinon.stub( balloon, 'updatePosition' ).returns( {} );
|
|
|
|
|
|
linkUIFeature._showUI();
|
|
|
- view.render();
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
linkUIFeature._hideUI();
|
|
|
|
|
|
linkUIFeature._showUI();
|
|
|
- view.render();
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
sinon.assert.calledTwice( spy );
|
|
|
} );
|
|
|
|
|
|
@@ -288,6 +288,9 @@ describe( 'LinkUI', () => {
|
|
|
writer.setSelection( Range.createFromParentsAndOffsets( text, 3, text, 3 ), true );
|
|
|
} );
|
|
|
|
|
|
+ // "Flush" throttled event.
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
+
|
|
|
sinon.assert.calledOnce( spy );
|
|
|
sinon.assert.calledWithExactly( spy, {
|
|
|
target: view.domConverter.mapViewToDom( linkElement )
|
|
|
@@ -301,7 +304,6 @@ describe( 'LinkUI', () => {
|
|
|
linkUIFeature._showUI();
|
|
|
const spy = testUtils.sinon.stub( balloon, 'updatePosition' ).returns( {} );
|
|
|
|
|
|
- // Fires #render.
|
|
|
const root = viewDocument.getRoot();
|
|
|
const text = root.getChild( 0 ).getChild( 0 );
|
|
|
|
|
|
@@ -309,6 +311,9 @@ describe( 'LinkUI', () => {
|
|
|
writer.setSelection( Range.createFromParentsAndOffsets( text, 3, text, 3 ), true );
|
|
|
} );
|
|
|
|
|
|
+ // "Flush" throttled event.
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
+
|
|
|
sinon.assert.calledOnce( spy );
|
|
|
sinon.assert.calledWithExactly( spy, {
|
|
|
target: editorElement.ownerDocument.getSelection().getRangeAt( 0 )
|
|
|
@@ -332,6 +337,9 @@ describe( 'LinkUI', () => {
|
|
|
writer.setSelection( Range.createFromParentsAndOffsets( text, 1, text, 1 ), true );
|
|
|
} );
|
|
|
|
|
|
+ // "Flush" throttled event.
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
+
|
|
|
sinon.assert.calledOnce( spyHide );
|
|
|
sinon.assert.notCalled( spyUpdate );
|
|
|
} );
|
|
|
@@ -355,6 +363,9 @@ describe( 'LinkUI', () => {
|
|
|
writer.setSelection( Range.createFromParentsAndOffsets( text, 1, text, 2 ), true );
|
|
|
} );
|
|
|
|
|
|
+ // "Flush" throttled event.
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
+
|
|
|
sinon.assert.calledOnce( spyHide );
|
|
|
sinon.assert.notCalled( spyUpdate );
|
|
|
} );
|
|
|
@@ -376,6 +387,9 @@ describe( 'LinkUI', () => {
|
|
|
writer.setSelection( Range.createFromParentsAndOffsets( text, 1, text, 2 ), true );
|
|
|
} );
|
|
|
|
|
|
+ // "Flush" throttled event.
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
+
|
|
|
sinon.assert.calledOnce( spyHide );
|
|
|
sinon.assert.notCalled( spyUpdate );
|
|
|
} );
|
|
|
@@ -414,12 +428,12 @@ describe( 'LinkUI', () => {
|
|
|
} ).to.not.throw();
|
|
|
} );
|
|
|
|
|
|
- it( 'should clear #render listener from the ViewDocument', () => {
|
|
|
+ it( 'should clear ui#update listener from the ViewDocument', () => {
|
|
|
const spy = sinon.spy();
|
|
|
|
|
|
- linkUIFeature.listenTo( editor.editing.view, 'render', spy );
|
|
|
+ linkUIFeature.listenTo( editor.ui, 'update', spy );
|
|
|
linkUIFeature._hideUI();
|
|
|
- editor.editing.view.change( () => {} );
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
|
|
|
sinon.assert.notCalled( spy );
|
|
|
} );
|