Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #196 from ckeditor/t/192
Browse files Browse the repository at this point in the history
Fix: ContextualBalloon plugin should use BalloonPanelView#pin instead of #attachTo. Closes #192.
  • Loading branch information
oleq authored Apr 12, 2017
2 parents 09067aa + 01b70f7 commit 28dd457
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default class ContextualBalloon extends Plugin {
*/
_show( view ) {
return this.view.content.add( view ).then( () => {
this.view.attachTo( this._getBalloonPosition() );
this.view.pin( this._getBalloonPosition() );
} );
}

Expand Down
28 changes: 12 additions & 16 deletions tests/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ describe( 'ContextualBalloon', () => {
editor = newEditor;
balloon = editor.plugins.get( ContextualBalloon );

// We don't need to test attachTo method of BalloonPanel it's enough to check if was called with proper data.
// We don't need to test BalloonPanelView attachTo and pin methods it's enough to check if was called with proper data.
sinon.stub( balloon.view, 'attachTo', () => {} );
sinon.stub( balloon.view, 'pin', () => {} );

viewA = new View();
viewB = new View();
Expand Down Expand Up @@ -118,8 +119,12 @@ describe( 'ContextualBalloon', () => {
it( 'should add view to the stack and display in balloon attached using given position options', () => {
expect( balloon.view.content.length ).to.equal( 1 );
expect( balloon.view.content.get( 0 ) ).to.deep.equal( viewA );
expect( balloon.view.attachTo.calledOnce ).to.true;
expect( balloon.view.attachTo.firstCall.args[ 0 ] ).to.deep.equal( { target: 'fake' } );
expect( balloon.view.pin.calledOnce ).to.true;
expect( balloon.view.pin.firstCall.args[ 0 ] ).to.deep.equal( { target: 'fake' } );
} );

it( 'should pin balloon to the target element', () => {
sinon.assert.calledOnce( balloon.view.pin );
} );

it( 'should throw an error when try to add the same view more than once', () => {
Expand Down Expand Up @@ -147,13 +152,13 @@ describe( 'ContextualBalloon', () => {
position: { target: 'other' }
} )
.then( () => {
expect( balloon.view.attachTo.calledTwice ).to.true;
expect( balloon.view.pin.calledTwice ).to.true;

expect( balloon.view.attachTo.firstCall.args[ 0 ] ).to.deep.equal( {
expect( balloon.view.pin.firstCall.args[ 0 ] ).to.deep.equal( {
target: 'fake'
} );

expect( balloon.view.attachTo.secondCall.args[ 0 ] ).to.deep.equal( {
expect( balloon.view.pin.secondCall.args[ 0 ] ).to.deep.equal( {
target: 'fake'
} );
} );
Expand Down Expand Up @@ -254,16 +259,7 @@ describe( 'ContextualBalloon', () => {
} );

describe( 'updatePosition()', () => {
it( 'should attach balloon to the target using the same position options as currently set', () => {
balloon.view.attachTo.reset();

balloon.updatePosition();

expect( balloon.view.attachTo.calledOnce );
expect( balloon.view.attachTo.firstCall.args[ 0 ] ).to.deep.equal( { target: 'fake' } );
} );

it( 'should attach balloon to the target using the same position options as currently set when there is more than one view', () => {
it( 'should attach balloon to the target using the same position options as first view in the stack', () => {
balloon.add( {
view: viewB,
position: {
Expand Down

0 comments on commit 28dd457

Please sign in to comment.