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 #27 from ckeditor/t/ckeditor5/1477
Browse files Browse the repository at this point in the history
Tests: Adjustments to new `data#ready` event.
  • Loading branch information
Piotr Jasiun committed Jan 29, 2019
2 parents 54af464 + e7a08f4 commit d38c8a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
5 changes: 1 addition & 4 deletions src/ballooneditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ export default class BalloonEditor extends Editor {

return editor.data.init( initialData );
} )
.then( () => {
editor.fire( 'dataReady' );
editor.fire( 'ready' );
} )
.then( () => editor.fire( 'ready' ))
.then( () => editor )
);
} );
Expand Down
30 changes: 4 additions & 26 deletions tests/ballooneditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,13 @@ describe( 'BalloonEditor', () => {
const fired = [];

function spy( evt ) {
fired.push( evt.name );
fired.push( `${ evt.name }-${ evt.source.constructor.name.toLowerCase() }` );
}

class EventWatcher extends Plugin {
init() {
this.editor.on( 'pluginsReady', spy );
this.editor.ui.on( 'ready', spy );
this.editor.on( 'dataReady', spy );
this.editor.data.on( 'ready', spy );
this.editor.on( 'ready', spy );
}
}
Expand All @@ -219,29 +218,8 @@ describe( 'BalloonEditor', () => {
plugins: [ EventWatcher ]
} )
.then( newEditor => {
expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] );

editor = newEditor;
} );
} );

it( 'fires dataReady once data is loaded', () => {
let data;

class EventWatcher extends Plugin {
init() {
this.editor.on( 'dataReady', () => {
data = this.editor.getData();
} );
}
}

return BalloonEditor
.create( editorElement, {
plugins: [ EventWatcher, Paragraph, Bold ]
} )
.then( newEditor => {
expect( data ).to.equal( '<p><strong>foo</strong> bar</p>' );
expect( fired ).to.deep.equal(
[ 'ready-ballooneditorui', 'ready-datacontroller', 'ready-ballooneditor' ] );

editor = newEditor;
} );
Expand Down
1 change: 0 additions & 1 deletion tests/ballooneditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ class VirtualBalloonTestEditor extends VirtualTestEditor {
editor.initPlugins()
.then( () => {
editor.ui.init();
editor.fire( 'dataReady' );
editor.fire( 'ready' );
} )
.then( () => editor )
Expand Down

0 comments on commit d38c8a8

Please sign in to comment.