Przeglądaj źródła

Aligned tests to changes in the core.

Piotrek Koszuliński 9 lat temu
rodzic
commit
f1a6164e7c

+ 6 - 10
packages/ckeditor5-enter/tests/enter.js

@@ -5,8 +5,7 @@
 
 'use strict';
 
-import Editor from '/ckeditor5/editor.js';
-import StandardCreator from '/ckeditor5/creator/standardcreator.js';
+import VirtualTestEditor from '/tests/ckeditor5/_utils/virtualtesteditor.js';
 import Enter from '/ckeditor5/enter/enter.js';
 import EnterCommand from '/ckeditor5/enter/entercommand.js';
 import DomEventData from '/ckeditor5/engine/view/observer/domeventdata.js';
@@ -15,14 +14,11 @@ describe( 'Enter feature', () => {
 	let editor, editingView;
 
 	beforeEach( () => {
-		editor = new Editor( null, {
-			creator: StandardCreator,
-			features: [ Enter ]
-		} );
-
-		return editor.init()
-			.then( () => {
-				editor.document.createRoot( 'main' );
+		return VirtualTestEditor.create( {
+				features: [ Enter ]
+			} )
+			.then( newEditor => {
+				editor = newEditor;
 				editingView = editor.editing.view;
 			} );
 	} );

+ 15 - 13
packages/ckeditor5-enter/tests/entercommand.js

@@ -5,29 +5,31 @@
 
 'use strict';
 
-import Editor from '/ckeditor5/editor.js';
-import Document from '/ckeditor5/engine/model/document.js';
+import VirtualTestEditor from '/tests/ckeditor5/_utils/virtualtesteditor.js';
 import { default as EnterCommand, enterBlock } from '/ckeditor5/enter/entercommand.js';
 import { getData, setData } from '/tests/engine/_utils/model.js';
 
 let editor, doc;
 
 beforeEach( () => {
-	editor = new Editor();
-	doc = editor.document = new Document();
+	return VirtualTestEditor.create( )
+		.then( newEditor => {
+			editor = newEditor;
+			doc = editor.document;
 
-	doc.createRoot( 'main', '$root' );
+			doc.createRoot();
 
-	const command = new EnterCommand( editor );
-	editor.commands.set( 'enter', command );
+			const command = new EnterCommand( editor );
+			editor.commands.set( 'enter', command );
 
-	const schema = doc.schema;
+			const schema = doc.schema;
 
-	// Note: We could use real names like 'paragraph', but that would make test patterns too long.
-	// Plus, this is actually a good test that the algorithm can be used for any model.
-	schema.registerItem( 'img', '$inline' );
-	schema.registerItem( 'p', '$block' );
-	schema.registerItem( 'h', '$block' );
+			// Note: We could use real names like 'paragraph', but that would make test patterns too long.
+			// Plus, this is actually a good test that the algorithm can be used for any model.
+			schema.registerItem( 'img', '$inline' );
+			schema.registerItem( 'p', '$block' );
+			schema.registerItem( 'h', '$block' );
+		} );
 } );
 
 describe( 'EnterCommand', () => {