浏览代码

Tests: fixes in LiveRange and LivePosition tests.

Szymon Cofalik 9 年之前
父节点
当前提交
91ed0cbe92
共有 2 个文件被更改,包括 31 次插入21 次删除
  1. 14 4
      packages/ckeditor5-engine/tests/model/liveposition.js
  2. 17 17
      packages/ckeditor5-engine/tests/model/liverange.js

+ 14 - 4
packages/ckeditor5-engine/tests/model/liveposition.js

@@ -264,13 +264,18 @@ describe( 'LivePosition', () => {
 			} );
 
 			it( 'is at the same position and live position is sticking to left side', () => {
-				let live = new LivePosition( root, path, 'sticksToPrevious' );
+				let newLive = new LivePosition( root, path, 'sticksToPrevious' );
+				spy = sinon.spy();
+				newLive.on( 'change', spy );
+
 				let insertRange = new Range( new Position( root, [ 1, 4, 6 ] ), new Position( root, [ 1, 4, 9 ] ) );
 
 				doc.fire( 'change', 'insert', { range: insertRange }, null );
 
-				expect( live.path ).to.deep.equal( path );
+				expect( newLive.path ).to.deep.equal( path );
 				expect( spy.called ).to.be.false;
+
+				newLive.detach();
 			} );
 
 			it( 'is after a node from the position path', () => {
@@ -308,7 +313,10 @@ describe( 'LivePosition', () => {
 			} );
 
 			it( 'is at the same position and live position is sticking to left side', () => {
-				let live = new LivePosition( root, path, 'sticksToPrevious' );
+				let newLive = new LivePosition( root, path, 'sticksToPrevious' );
+				spy = sinon.spy();
+				newLive.on( 'change', spy );
+
 				let moveSource = new Position( root, [ 2 ] );
 				let moveRange = new Range( new Position( root, [ 1, 4, 6 ] ), new Position( root, [ 1, 4, 9 ] ) );
 
@@ -318,8 +326,10 @@ describe( 'LivePosition', () => {
 				};
 				doc.fire( 'change', 'move', changes, null );
 
-				expect( live.path ).to.deep.equal( path );
+				expect( newLive.path ).to.deep.equal( path );
 				expect( spy.called ).to.be.false;
+
+				newLive.detach();
 			} );
 
 			it( 'is at a position after a node from the live position path', () => {

+ 17 - 17
packages/ckeditor5-engine/tests/model/liverange.js

@@ -363,23 +363,6 @@ describe( 'LiveRange', () => {
 				expect( spy.calledOnce ).to.be.true;
 			} );
 
-			it( 'is inside live range and points to live range', () => {
-				live.end.path = [ 0, 1, 12 ];
-
-				let moveSource = new Position( root, [ 0, 1, 6 ] );
-				let moveRange = new Range( new Position( root, [ 0, 1, 8 ] ), new Position( root, [ 0, 1, 10 ] ) );
-
-				let changes = {
-					range: moveRange,
-					sourcePosition: moveSource
-				};
-				doc.fire( 'change', 'move', changes, null );
-
-				expect( live.start.path ).to.deep.equal( [ 0, 1, 4 ] );
-				expect( live.end.path ).to.deep.equal( [ 0, 1, 12 ] );
-				expect( spy.calledOnce ).to.be.true;
-			} );
-
 			it( 'is intersecting with live range and points to live range', () => {
 				live.end.path = [ 0, 1, 12 ];
 
@@ -570,6 +553,23 @@ describe( 'LiveRange', () => {
 				expect( live.isEqual( clone ) ).to.be.true;
 				expect( spy.called ).to.be.false;
 			} );
+
+			it( 'is inside live range and points to live range', () => {
+				live.end.path = [ 0, 1, 12 ];
+
+				let moveSource = new Position( root, [ 0, 1, 6 ] );
+				let moveRange = new Range( new Position( root, [ 0, 1, 8 ] ), new Position( root, [ 0, 1, 10 ] ) );
+
+				let changes = {
+					range: moveRange,
+					sourcePosition: moveSource
+				};
+				doc.fire( 'change', 'move', changes, null );
+
+				expect( live.start.path ).to.deep.equal( [ 0, 1, 4 ] );
+				expect( live.end.path ).to.deep.equal( [ 0, 1, 12 ] );
+				expect( spy.calledOnce ).to.be.false;
+			} );
 		} );
 	} );
 } );