|
@@ -18,6 +18,7 @@ import DataApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/dataapimixin
|
|
|
import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
|
|
import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
|
|
|
|
|
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
|
|
+import log from '@ckeditor/ckeditor5-utils/src/log';
|
|
|
|
|
|
|
|
const editorData = '<p><strong>foo</strong> bar</p>';
|
|
const editorData = '<p><strong>foo</strong> bar</p>';
|
|
|
|
|
|
|
@@ -26,6 +27,10 @@ describe( 'DecoupledEditor', () => {
|
|
|
|
|
|
|
|
testUtils.createSinonSandbox();
|
|
testUtils.createSinonSandbox();
|
|
|
|
|
|
|
|
|
|
+ beforeEach( () => {
|
|
|
|
|
+ testUtils.sinon.stub( log, 'warn' ).callsFake( () => {} );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
describe( 'constructor()', () => {
|
|
describe( 'constructor()', () => {
|
|
|
beforeEach( () => {
|
|
beforeEach( () => {
|
|
|
editor = new DecoupledEditor();
|
|
editor = new DecoupledEditor();
|
|
@@ -189,6 +194,7 @@ describe( 'DecoupledEditor', () => {
|
|
|
class EventWatcher extends Plugin {
|
|
class EventWatcher extends Plugin {
|
|
|
init() {
|
|
init() {
|
|
|
this.editor.on( 'pluginsReady', spy );
|
|
this.editor.on( 'pluginsReady', spy );
|
|
|
|
|
+ this.editor.ui.on( 'ready', spy );
|
|
|
this.editor.on( 'uiReady', spy );
|
|
this.editor.on( 'uiReady', spy );
|
|
|
this.editor.on( 'dataReady', spy );
|
|
this.editor.on( 'dataReady', spy );
|
|
|
this.editor.on( 'ready', spy );
|
|
this.editor.on( 'ready', spy );
|
|
@@ -200,7 +206,7 @@ describe( 'DecoupledEditor', () => {
|
|
|
plugins: [ EventWatcher ]
|
|
plugins: [ EventWatcher ]
|
|
|
} )
|
|
} )
|
|
|
.then( newEditor => {
|
|
.then( newEditor => {
|
|
|
- expect( fired ).to.deep.equal( [ 'pluginsReady', 'uiReady', 'dataReady', 'ready' ] );
|
|
|
|
|
|
|
+ expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'uiReady', 'dataReady', 'ready' ] );
|
|
|
|
|
|
|
|
return newEditor.destroy();
|
|
return newEditor.destroy();
|
|
|
} );
|
|
} );
|
|
@@ -249,6 +255,28 @@ describe( 'DecoupledEditor', () => {
|
|
|
return newEditor.destroy();
|
|
return newEditor.destroy();
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'fires ready once UI is rendered', () => {
|
|
|
|
|
+ let isReady;
|
|
|
|
|
+
|
|
|
|
|
+ class EventWatcher extends Plugin {
|
|
|
|
|
+ init() {
|
|
|
|
|
+ this.editor.ui.on( 'ready', () => {
|
|
|
|
|
+ isReady = this.editor.ui.view.isRendered;
|
|
|
|
|
+ } );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return DecoupledEditor
|
|
|
|
|
+ .create( getElementOrData(), {
|
|
|
|
|
+ plugins: [ EventWatcher ]
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( newEditor => {
|
|
|
|
|
+ expect( isReady ).to.be.true;
|
|
|
|
|
+
|
|
|
|
|
+ return newEditor.destroy();
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
}
|
|
}
|
|
|
} );
|
|
} );
|