8
0
Quellcode durchsuchen

Tests: updated tests for LiveRange and LiveSelection.

Szymon Cofalik vor 8 Jahren
Ursprung
Commit
063fe4a8bd

+ 4 - 21
packages/ckeditor5-engine/tests/model/liverange.js

@@ -295,26 +295,9 @@ describe( 'LiveRange', () => {
 				expect( spy.calledOnce ).to.be.true;
 			} );
 
-			it( 'intersects on live range left side and live range new start is touching moved range end', () => {
-				let moveSource = new Position( root, [ 0, 1, 0 ] );
-				let moveRange = new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 6 ] ) );
-
-				let changes = {
-					range: moveRange,
-					sourcePosition: moveSource
-				};
-				doc.fire( 'change', 'move', changes, null );
-
-				expect( live.start.path ).to.deep.equal( [ 0, 5 ] );
-				expect( live.end.path ).to.deep.equal( [ 0, 7, 2 ] );
-				expect( spy.calledOnce ).to.be.true;
-			} );
-
-			it( 'intersects on live range right side and live range new end is touching moved range start', () => {
-				live.end.offset = 12;
-
-				let moveSource = new Position( root, [ 0, 2, 10 ] );
-				let moveRange = new Range( new Position( root, [ 0, 3, 0 ] ), new Position( root, [ 0, 3, 5 ] ) );
+			it( 'intersects with live range and is moved into live range', () => {
+				let moveSource = new Position( root, [ 0, 2, 1 ] );
+				let moveRange = new Range( new Position( root, [ 0, 2, 0 ] ), new Position( root, [ 0, 2, 5 ] ) );
 
 				let changes = {
 					range: moveRange,
@@ -323,7 +306,7 @@ describe( 'LiveRange', () => {
 				doc.fire( 'change', 'move', changes, null );
 
 				expect( live.start.path ).to.deep.equal( [ 0, 1, 4 ] );
-				expect( live.end.path ).to.deep.equal( [ 0, 3, 2 ] );
+				expect( live.end.path ).to.deep.equal( [ 0, 2, 6 ] );
 				expect( spy.calledOnce ).to.be.true;
 			} );
 

+ 20 - 15
packages/ckeditor5-engine/tests/model/liveselection.js

@@ -14,6 +14,7 @@ import InsertOperation from '../../src/model/operation/insertoperation';
 import MoveOperation from '../../src/model/operation/moveoperation';
 import RemoveOperation from '../../src/model/operation/removeoperation';
 import AttributeOperation from '../../src/model/operation/attributeoperation';
+import SplitDelta from '../../src/model/delta/splitdelta';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import count from '@ckeditor/ckeditor5-utils/src/count';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
@@ -461,22 +462,26 @@ describe( 'LiveSelection', () => {
 					expect( data.directChange ).to.be.false;
 				} );
 
-				doc.applyOperation( wrapInDelta(
-					new InsertOperation(
-						new Position( root, [ 2 ] ),
-						new Element( 'p' ),
-						doc.version
-					)
-				) );
+				const splitDelta = new SplitDelta();
 
-				doc.applyOperation( wrapInDelta(
-					new MoveOperation(
-						new Position( root, [ 1, 2 ] ),
-						4,
-						new Position( root, [ 2, 0 ] ),
-						doc.version
-					)
-				) );
+				const insertOperation = new InsertOperation(
+					new Position( root, [ 2 ] ),
+					new Element( 'p' ),
+					0
+				);
+
+				const moveOperation = new MoveOperation(
+					new Position( root, [ 1, 2 ] ),
+					4,
+					new Position( root, [ 2, 0 ] ),
+					1
+				);
+
+				splitDelta.addOperation( insertOperation );
+				splitDelta.addOperation( moveOperation );
+
+				doc.applyOperation( insertOperation );
+				doc.applyOperation( moveOperation );
 
 				let range = selection.getFirstRange();