From 3bb552e0aa419efce996d9f3130fb9ab13c50961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Krzto=C5=84?= Date: Wed, 23 Jan 2019 13:43:55 +0100 Subject: [PATCH 1/3] Tests: Adjust unit tests to 'plugincollection#ready' event. --- tests/classiceditor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/classiceditor.js b/tests/classiceditor.js index 5838375..98a09d2 100644 --- a/tests/classiceditor.js +++ b/tests/classiceditor.js @@ -187,12 +187,12 @@ describe( 'ClassicEditor', () => { 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.plugins.on( 'ready', spy ); this.editor.ui.on( 'ready', spy ); this.editor.on( 'dataReady', spy ); this.editor.on( 'ready', spy ); @@ -204,7 +204,8 @@ describe( 'ClassicEditor', () => { plugins: [ EventWatcher ] } ) .then( newEditor => { - expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] ); + expect( fired ).to.deep.equal( + [ 'ready-plugincollection', 'ready-classiceditorui', 'dataReady-classiceditor', 'ready-classiceditor' ] ); editor = newEditor; } ); From f112156c207bd1d2dd8cd3b5c7ef6c8a92fcfd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Krzto=C5=84?= Date: Thu, 24 Jan 2019 11:26:48 +0100 Subject: [PATCH 2/3] Adjustments to new data#ready event. --- src/classiceditor.js | 5 +---- tests/classiceditor.js | 26 ++------------------------ tests/classiceditorui.js | 1 - 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/classiceditor.js b/src/classiceditor.js index 3a360e6..4550f57 100644 --- a/src/classiceditor.js +++ b/src/classiceditor.js @@ -181,10 +181,7 @@ export default class ClassicEditor extends Editor { return editor.data.init( initialData ); } ) - .then( () => { - editor.fire( 'dataReady' ); - editor.fire( 'ready' ); - } ) + .then( () => editor.fire( 'ready' ) ) .then( () => editor ) ); } ); diff --git a/tests/classiceditor.js b/tests/classiceditor.js index 98a09d2..b222fe9 100644 --- a/tests/classiceditor.js +++ b/tests/classiceditor.js @@ -194,7 +194,7 @@ describe( 'ClassicEditor', () => { init() { this.editor.plugins.on( 'ready', spy ); this.editor.ui.on( 'ready', spy ); - this.editor.on( 'dataReady', spy ); + this.editor.data.on( 'ready', spy ); this.editor.on( 'ready', spy ); } } @@ -205,29 +205,7 @@ describe( 'ClassicEditor', () => { } ) .then( newEditor => { expect( fired ).to.deep.equal( - [ 'ready-plugincollection', 'ready-classiceditorui', 'dataReady-classiceditor', 'ready-classiceditor' ] ); - - 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 ClassicEditor - .create( editorElement, { - plugins: [ EventWatcher, Paragraph, Bold ] - } ) - .then( newEditor => { - expect( data ).to.equal( '

foo bar

' ); + [ 'ready-plugincollection', 'ready-classiceditorui', 'ready-datacontroller', 'ready-classiceditor' ] ); editor = newEditor; } ); diff --git a/tests/classiceditorui.js b/tests/classiceditorui.js index 73deaba..63831e2 100644 --- a/tests/classiceditorui.js +++ b/tests/classiceditorui.js @@ -243,7 +243,6 @@ class VirtualClassicTestEditor extends VirtualTestEditor { editor.initPlugins() .then( () => { editor.ui.init(); - editor.fire( 'dataReady' ); editor.fire( 'ready' ); } ) .then( () => editor ) From d6da164021512046de26ffa9d7c5339d9db03f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Krzto=C5=84?= Date: Mon, 28 Jan 2019 17:41:27 +0100 Subject: [PATCH 3/3] Tests: Adjustments. --- tests/classiceditor.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/classiceditor.js b/tests/classiceditor.js index b222fe9..04120d6 100644 --- a/tests/classiceditor.js +++ b/tests/classiceditor.js @@ -192,7 +192,6 @@ describe( 'ClassicEditor', () => { class EventWatcher extends Plugin { init() { - this.editor.plugins.on( 'ready', spy ); this.editor.ui.on( 'ready', spy ); this.editor.data.on( 'ready', spy ); this.editor.on( 'ready', spy ); @@ -205,7 +204,7 @@ describe( 'ClassicEditor', () => { } ) .then( newEditor => { expect( fired ).to.deep.equal( - [ 'ready-plugincollection', 'ready-classiceditorui', 'ready-datacontroller', 'ready-classiceditor' ] ); + [ 'ready-classiceditorui', 'ready-datacontroller', 'ready-classiceditor' ] ); editor = newEditor; } );