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

Using view Selection instead DocumentSelection in tests.

Szymon Kupś 7 лет назад
Родитель
Сommit
aa98ff6f15

+ 14 - 14
packages/ckeditor5-typing/tests/input.js

@@ -15,7 +15,7 @@ import ModelRange from '@ckeditor/ckeditor5-engine/src/model/range';
 
 import ViewText from '@ckeditor/ckeditor5-engine/src/view/text';
 import ViewElement from '@ckeditor/ckeditor5-engine/src/view/element';
-import ViewDocumentSelection from '@ckeditor/ckeditor5-engine/src/view/documentselection';
+import ViewSelection from '@ckeditor/ckeditor5-engine/src/view/selection';
 
 import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
 import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
@@ -262,8 +262,8 @@ describe( 'Input feature', () => {
 		it( 'should set model selection appropriately to view selection passed in mutations event', () => {
 			// This test case emulates spellchecker correction.
 
-			const viewSelection = new ViewDocumentSelection();
-			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
+			const viewSelection = new ViewSelection();
+			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
 
 			viewDocument.fire( 'mutations',
 				[ {
@@ -282,8 +282,8 @@ describe( 'Input feature', () => {
 		it( 'should use up to one insert and remove operations (spellchecker)', () => {
 			// This test case emulates spellchecker correction.
 
-			const viewSelection = new ViewDocumentSelection();
-			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
+			const viewSelection = new ViewSelection();
+			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
 
 			testUtils.sinon.spy( Writer.prototype, 'insert' );
 			testUtils.sinon.spy( Writer.prototype, 'remove' );
@@ -306,8 +306,8 @@ describe( 'Input feature', () => {
 			// This test case emulates spellchecker correction.
 			editor.setData( '<p>Foo hous a</p>' );
 
-			const viewSelection = new ViewDocumentSelection();
-			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+			const viewSelection = new ViewSelection();
+			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
 
 			viewDocument.fire( 'mutations',
 				[ {
@@ -327,8 +327,8 @@ describe( 'Input feature', () => {
 			// This test case emulates spellchecker correction.
 			editor.setData( '<p>Bar athat foo</p>' );
 
-			const viewSelection = new ViewDocumentSelection();
-			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
+			const viewSelection = new ViewSelection();
+			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
 
 			viewDocument.fire( 'mutations',
 				[ {
@@ -348,8 +348,8 @@ describe( 'Input feature', () => {
 			// This test case emulates spellchecker correction.
 			editor.setData( '<p>Foo hous e</p>' );
 
-			const viewSelection = new ViewDocumentSelection();
-			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+			const viewSelection = new ViewSelection();
+			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
 
 			viewDocument.fire( 'mutations',
 				[ {
@@ -368,9 +368,9 @@ describe( 'Input feature', () => {
 		it( 'should place non-collapsed selection after changing single character (composition)', () => {
 			editor.setData( '<p>Foo house</p>' );
 
-			const viewSelection = new ViewDocumentSelection();
-			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
-			viewSelection._setFocus( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+			const viewSelection = new ViewSelection();
+			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
+			viewSelection.setFocus( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
 
 			viewDocument.fire( 'mutations',
 				[ {

+ 3 - 3
packages/ckeditor5-typing/tests/spellchecking.js

@@ -14,7 +14,7 @@ import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 
 import ModelRange from '@ckeditor/ckeditor5-engine/src/model/range';
 
-import ViewDocumentSelection from '@ckeditor/ckeditor5-engine/src/view/documentselection';
+import ViewSelection from '@ckeditor/ckeditor5-engine/src/view/selection';
 
 import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
@@ -234,9 +234,9 @@ describe( 'Typing – spellchecking integration', () => {
 function emulateSpellcheckerMutation( editor, nodeIndex, resultPositionIndex, oldText, newText ) {
 	const view = editor.editing.view;
 	const viewRoot = view.document.getRoot();
-	const viewSelection = new ViewDocumentSelection();
+	const viewSelection = new ViewSelection();
 
-	viewSelection._setTo( viewRoot.getChild( nodeIndex ).getChild( 0 ), resultPositionIndex );
+	viewSelection.setTo( viewRoot.getChild( nodeIndex ).getChild( 0 ), resultPositionIndex );
 
 	view.document.fire( 'mutations',
 		[ {

+ 3 - 3
packages/ckeditor5-typing/tests/tickets/100.js

@@ -16,7 +16,7 @@ import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversio
 import ViewText from '@ckeditor/ckeditor5-engine/src/view/text';
 import ViewElement from '@ckeditor/ckeditor5-engine/src/view/element';
 import ViewContainerElement from '@ckeditor/ckeditor5-engine/src/view/containerelement';
-import ViewDocumentSelection from '@ckeditor/ckeditor5-engine/src/view/documentselection';
+import ViewSelection from '@ckeditor/ckeditor5-engine/src/view/selection';
 import MutationObserver from '@ckeditor/ckeditor5-engine/src/view/observer/mutationobserver';
 
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
@@ -402,7 +402,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		const paragraph = viewRoot.getChild( 0 );
 		const strong = paragraph.getChild( 0 );
-		const viewSelection = new ViewDocumentSelection( paragraph, 0 );
+		const viewSelection = new ViewSelection( paragraph, 0 );
 
 		// Simulate mutations and DOM change.
 		domRoot.childNodes[ 0 ].innerHTML = '<b>textx</b>';
@@ -426,7 +426,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		const paragraph = viewRoot.getChild( 0 );
 		const strong = paragraph.getChild( 0 );
-		const viewSelection = new ViewDocumentSelection( paragraph, 0 );
+		const viewSelection = new ViewSelection( paragraph, 0 );
 
 		// Simulate mutations and DOM change.
 		domRoot.childNodes[ 0 ].innerHTML = '<strong>Foo bar </strong><b>apple</b>';