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 #46 from ckeditor/t/45
Browse files Browse the repository at this point in the history
Fix: Pass CKFinder instance to a user-defined onInit() function. Closes #45.
  • Loading branch information
Reinmar authored Aug 8, 2019
2 parents d111af4 + 17ea5a0 commit e53558c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ckfindercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class CKFinderCommand extends Command {
options.onInit = finder => {
// Call original options.onInit if it was defined by user.
if ( originalOnInit ) {
originalOnInit();
originalOnInit( finder );
}

finder.on( 'files:choose', evt => {
Expand Down
12 changes: 11 additions & 1 deletion tests/ckfindercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe( 'CKFinderCommand', () => {
expect( openerMethodOptions ).to.have.property( 'connectorPath', connectorPath );
} );

it( 'should call user defined config.onInit() function', () => {
it( 'should call user-defined config.onInit() function', () => {
const spy = sinon.spy();

editor.config.set( 'ckfinder.options.onInit', spy );
Expand All @@ -204,6 +204,16 @@ describe( 'CKFinderCommand', () => {
sinon.assert.calledOnce( spy );
} );

it( 'should pass CKFinder instance to a user-defined config.onInit() function', () => {
const spy = sinon.spy();

editor.config.set( 'ckfinder.options.onInit', spy );

command.execute();

sinon.assert.calledWithExactly( spy, finderMock );
} );

it( 'should pass editor default language to the CKFinder instance', () => {
const spy = sinon.spy( window.CKFinder, 'modal' );
command.execute();
Expand Down

0 comments on commit e53558c

Please sign in to comment.