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

Adjustments to new data#ready event #27

Merged
merged 4 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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