8
0
Просмотр исходного кода

Tests: Test editor adjustments.

Krzysztof Krztoń 7 лет назад
Родитель
Сommit
3f00f7cd71

+ 24 - 15
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -38,9 +38,6 @@ export default class ClassicTestEditor extends Editor {
 		// Expose properties normally exposed by the ClassicEditorUI.
 		this.ui.view.editable = new InlineEditableUIView( this.ui.view.locale );
 
-		// A helper to easily replace the editor#element with editor.editable#element.
-		this._elementReplacer = new ElementReplacer();
-
 		// Create the ("main") root element of the model tree.
 		this.model.document.createRoot();
 	}
@@ -49,7 +46,6 @@ export default class ClassicTestEditor extends Editor {
 	 * @inheritDoc
 	 */
 	destroy() {
-		this._elementReplacer.restore();
 		this.ui.destroy();
 
 		return super.destroy();
@@ -66,17 +62,7 @@ export default class ClassicTestEditor extends Editor {
 				editor.initPlugins()
 					// Simulate EditorUI.init() (e.g. like in ClassicEditorUI). The ui#view
 					// should be rendered after plugins are initialized.
-					.then( () => {
-						const view = editor.ui.view;
-
-						view.render();
-						view.main.add( view.editable );
-						view.editableElement = view.editable.element;
-					} )
-					.then( () => {
-						editor._elementReplacer.replace( element, editor.ui.view.element );
-						editor.ui.ready();
-					} )
+					.then( () => editor.ui.init( element ) )
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.view.editableElement ) )
 					.then( () => editor.data.init( getDataFromElement( element ) ) )
 					.then( () => {
@@ -103,6 +89,9 @@ class ClassicTestEditorUI extends EditorUI {
 	constructor( editor, view ) {
 		super( editor );
 
+		// A helper to easily replace the editor#element with editor.editable#element.
+		this._elementReplacer = new ElementReplacer();
+
 		this._view = view;
 	}
 
@@ -115,6 +104,26 @@ class ClassicTestEditorUI extends EditorUI {
 	get view() {
 		return this._view;
 	}
+
+	init( element ) {
+		const view = this.view;
+
+		view.render();
+		view.main.add( view.editable );
+		view.editableElement = view.editable.element;
+
+		this._elementReplacer.replace( element, this.view.element );
+
+		this.fire( 'ready' );
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	destroy() {
+		this._elementReplacer.restore();
+		super.destroy();
+	}
 }
 
 mix( ClassicTestEditor, DataApiMixin );

+ 0 - 16
packages/ckeditor5-core/tests/editor/editorui.js

@@ -78,22 +78,6 @@ describe( 'EditorUI', () => {
 		} );
 	} );
 
-	describe( 'ready()', () => {
-		it( 'should fire ready event', () => {
-			const spy = sinon.spy();
-
-			ui.on( 'ready', spy );
-
-			ui.ready();
-
-			sinon.assert.calledOnce( spy );
-
-			ui.ready();
-
-			sinon.assert.calledTwice( spy );
-		} );
-	} );
-
 	describe( 'update()', () => {
 		it( 'should fire update event', () => {
 			const spy = sinon.spy();