소스 검색

Tests: additional improvements in treeModel connected with treeModel.NodeList compression.

Szymon Cofalik 10 년 전
부모
커밋
88d50393c0

+ 1 - 1
packages/ckeditor5-engine/tests/treemodel/delta/weakinsertdelta.js

@@ -32,7 +32,7 @@ describe( 'Batch', () => {
 		chain = batch.weakInsert( new Position( root, [ 2 ] ), 'xyz' );
 	} );
 
-	describe( 'insert', () => {
+	describe( 'weakInsert', () => {
 		it( 'should insert given nodes at given position', () => {
 			expect( root.getChildCount() ).to.equal( 6 );
 			expect( root.getChild( 2 ).text ).to.equal( 'x' );

+ 0 - 6
packages/ckeditor5-engine/tests/treemodel/element.js

@@ -66,18 +66,12 @@ describe( 'Element', () => {
 	describe( 'removeChildren', () => {
 		it( 'should remove children from the element and return them as a NodeList', () => {
 			let element = new Element( 'elem', [], [ 'foobar' ] );
-			let o = element.getChild( 2 );
-			let b = element.getChild( 3 );
-			let a = element.getChild( 4 );
 			let removed = element.removeChildren( 2, 3 );
 
 			expect( element.getChildCount() ).to.equal( 3 );
 			expect( element.getChild( 0 ) ).to.have.property( 'text' ).that.equals( 'f' );
 			expect( element.getChild( 1 ) ).to.have.property( 'text' ).that.equals( 'o' );
 			expect( element.getChild( 2 ) ).to.have.property( 'text' ).that.equals( 'r' );
-			expect( o ).to.have.property( 'parent' ).that.is.null;
-			expect( b ).to.have.property( 'parent' ).that.is.null;
-			expect( a ).to.have.property( 'parent' ).that.is.null;
 
 			expect( removed ).to.be.instanceof( NodeList );
 			expect( removed.length ).to.equal( 3 );

+ 6 - 12
packages/ckeditor5-engine/tests/treemodel/node.js

@@ -10,7 +10,6 @@
 import Element from '/ckeditor5/core/treemodel/element.js';
 import Attribute from '/ckeditor5/core/treemodel/attribute.js';
 import AttributeList from '/ckeditor5/core/treemodel/attributelist.js';
-import NodeList from '/ckeditor5/core/treemodel/nodelist.js';
 import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
 
 describe( 'Node', () => {
@@ -54,10 +53,7 @@ describe( 'Node', () => {
 			expect( two ).to.have.property( 'root' ).that.equals( root );
 			expect( three ).to.have.property( 'root' ).that.equals( root );
 
-			expect( charB ).to.have.property( 'root' ).that.equals( root );
-			expect( charA ).to.have.property( 'root' ).that.equals( root );
 			expect( img ).to.have.property( 'root' ).that.equals( root );
-			expect( charR ).to.have.property( 'root' ).that.equals( root );
 		} );
 
 		it( 'nextSibling', () => {
@@ -67,9 +63,9 @@ describe( 'Node', () => {
 			expect( two ).to.have.property( 'nextSibling' ).that.equals( three );
 			expect( three ).to.have.property( 'nextSibling' ).that.is.null;
 
-			expect( charB ).to.have.property( 'nextSibling' ).that.equals( charA );
-			expect( charA ).to.have.property( 'nextSibling' ).that.equals( img );
-			expect( img ).to.have.property( 'nextSibling' ).that.equals( charR );
+			expect( charB ).to.have.property( 'nextSibling' ).that.deep.equals( charA );
+			expect( charA ).to.have.property( 'nextSibling' ).that.deep.equals( img );
+			expect( img ).to.have.property( 'nextSibling' ).that.deep.equals( charR );
 			expect( charR ).to.have.property( 'nextSibling' ).that.is.null;
 		} );
 
@@ -81,9 +77,9 @@ describe( 'Node', () => {
 			expect( three ).to.have.property( 'previousSibling' ).that.equals( two );
 
 			expect( charB ).to.have.property( 'previousSibling' ).that.is.null;
-			expect( charA ).to.have.property( 'previousSibling' ).that.equals( charB );
-			expect( img ).to.have.property( 'previousSibling' ).that.equals( charA );
-			expect( charR ).to.have.property( 'previousSibling' ).that.equals( img );
+			expect( charA ).to.have.property( 'previousSibling' ).that.deep.equals( charB );
+			expect( img ).to.have.property( 'previousSibling' ).that.deep.equals( charA );
+			expect( charR ).to.have.property( 'previousSibling' ).that.deep.equals( img );
 		} );
 	} );
 
@@ -128,7 +124,6 @@ describe( 'Node', () => {
 			expect( three.getIndex() ).to.equal( 2 );
 
 			expect( charB.getIndex() ).to.equal( 0 );
-			expect( charA.getIndex() ).to.equal( 1 );
 			expect( img.getIndex() ).to.equal( 2 );
 			expect( charR.getIndex() ).to.equal( 3 );
 		} );
@@ -156,7 +151,6 @@ describe( 'Node', () => {
 			expect( three.getPath() ).to.deep.equal( [ 2 ] );
 
 			expect( charB.getPath() ).to.deep.equal( [ 1, 0 ] );
-			expect( charA.getPath() ).to.deep.equal( [ 1, 1 ] );
 			expect( img.getPath() ).to.deep.equal( [ 1, 2 ] );
 			expect( charR.getPath() ).to.deep.equal( [ 1, 3 ] );
 		} );

+ 22 - 22
packages/ckeditor5-engine/tests/treemodel/position.js

@@ -195,37 +195,37 @@ describe( 'position', () => {
 	} );
 
 	it( 'should have nodeBefore', () => {
-		expect( new Position( root, [ 0 ] ) ).to.have.property( 'nodeBefore' ).that.is.null;
-		expect( new Position( root, [ 1 ] ) ).to.have.property( 'nodeBefore' ).that.equals( p );
-		expect( new Position( root, [ 2 ] ) ).to.have.property( 'nodeBefore' ).that.equals( ul );
+		expect( new Position( root, [ 0 ] ).nodeBefore ).to.be.null;
+		expect( new Position( root, [ 1 ] ).nodeBefore ).to.equal( p );
+		expect( new Position( root, [ 2 ] ).nodeBefore ).to.equal( ul );
 
-		expect( new Position( root, [ 0, 0 ] ) ).to.have.property( 'nodeBefore' ).that.is.null;
+		expect( new Position( root, [ 0, 0 ] ).nodeBefore ).to.null;
 
-		expect( new Position( root, [ 1, 0 ] ) ).to.have.property( 'nodeBefore' ).that.is.null;
-		expect( new Position( root, [ 1, 1 ] ) ).to.have.property( 'nodeBefore' ).that.equals( li1 );
-		expect( new Position( root, [ 1, 2 ] ) ).to.have.property( 'nodeBefore' ).that.equals( li2 );
+		expect( new Position( root, [ 1, 0 ] ).nodeBefore ).to.be.null;
+		expect( new Position( root, [ 1, 1 ] ).nodeBefore ).to.equal( li1 );
+		expect( new Position( root, [ 1, 2 ] ).nodeBefore ).to.equal( li2 );
 
-		expect( new Position( root, [ 1, 0, 0 ] ) ).to.have.property( 'nodeBefore' ).that.is.null;
-		expect( new Position( root, [ 1, 0, 1 ] ) ).to.have.property( 'nodeBefore' ).that.equals( f );
-		expect( new Position( root, [ 1, 0, 2 ] ) ).to.have.property( 'nodeBefore' ).that.equals( o );
-		expect( new Position( root, [ 1, 0, 3 ] ) ).to.have.property( 'nodeBefore' ).that.equals( z );
+		expect( new Position( root, [ 1, 0, 0 ] ).nodeBefore ).to.be.null;
+		expect( new Position( root, [ 1, 0, 1 ] ).nodeBefore.text ).to.equal( 'f' );
+		expect( new Position( root, [ 1, 0, 2 ] ).nodeBefore.text ).to.equal( 'o' );
+		expect( new Position( root, [ 1, 0, 3 ] ).nodeBefore.text ).to.equal( 'z' );
 	} );
 
 	it( 'should have nodeAfter', () => {
-		expect( new Position( root, [ 0 ] ) ).to.have.property( 'nodeAfter' ).that.equals( p );
-		expect( new Position( root, [ 1 ] ) ).to.have.property( 'nodeAfter' ).that.equals( ul );
-		expect( new Position( root, [ 2 ] ) ).to.have.property( 'nodeAfter' ).that.is.null;
+		expect( new Position( root, [ 0 ] ).nodeAfter ).to.equal( p );
+		expect( new Position( root, [ 1 ] ).nodeAfter ).to.equal( ul );
+		expect( new Position( root, [ 2 ] ).nodeAfter ).to.be.null;
 
-		expect( new Position( root, [ 0, 0 ] ) ).to.have.property( 'nodeAfter' ).that.is.null;
+		expect( new Position( root, [ 0, 0 ] ).nodeAfter ).to.be.null;
 
-		expect( new Position( root, [ 1, 0 ] ) ).to.have.property( 'nodeAfter' ).that.equals( li1 );
-		expect( new Position( root, [ 1, 1 ] ) ).to.have.property( 'nodeAfter' ).that.equals( li2 );
-		expect( new Position( root, [ 1, 2 ] ) ).to.have.property( 'nodeAfter' ).that.is.null;
+		expect( new Position( root, [ 1, 0 ] ).nodeAfter ).to.equal( li1 );
+		expect( new Position( root, [ 1, 1 ] ).nodeAfter ).to.equal( li2 );
+		expect( new Position( root, [ 1, 2 ] ).nodeAfter ).to.be.null;
 
-		expect( new Position( root, [ 1, 0, 0 ] ) ).to.have.property( 'nodeAfter' ).that.equals( f );
-		expect( new Position( root, [ 1, 0, 1 ] ) ).to.have.property( 'nodeAfter' ).that.equals( o );
-		expect( new Position( root, [ 1, 0, 2 ] ) ).to.have.property( 'nodeAfter' ).that.equals( z );
-		expect( new Position( root, [ 1, 0, 3 ] ) ).to.have.property( 'nodeAfter' ).that.is.null;
+		expect( new Position( root, [ 1, 0, 0 ] ).nodeAfter.text ).to.equal( 'f' );
+		expect( new Position( root, [ 1, 0, 1 ] ).nodeAfter.text ).to.equal( 'o' );
+		expect( new Position( root, [ 1, 0, 2 ] ).nodeAfter.text ).to.equal( 'z' );
+		expect( new Position( root, [ 1, 0, 3 ] ).nodeAfter ).to.be.null;
 	} );
 
 	it( 'should have proper parent path', () => {