8
0
Quellcode durchsuchen

Increased code coverage to 100% of TextProxy.

Oskar Wrobel vor 9 Jahren
Ursprung
Commit
9a3a32840f
1 geänderte Dateien mit 14 neuen und 0 gelöschten Zeilen
  1. 14 0
      packages/ckeditor5-engine/tests/view/textproxy.js

+ 14 - 0
packages/ckeditor5-engine/tests/view/textproxy.js

@@ -33,6 +33,13 @@ describe( 'TextProxy', () => {
 			expect( textProxy ).to.have.property( '_textNode' ).to.equal( text );
 			expect( textProxy ).to.have.property( '_index' ).to.equal( 2 );
 		} );
+
+		it( 'should get text from specified offset to the end of textNode if length is not defined', () => {
+			textProxy = new TextProxy( text, 2 );
+
+			expect( textProxy ).to.have.property( '_data' ).to.equal( 'cdefgh' );
+			expect( textProxy ).to.have.property( '_index' ).to.equal( 2 );
+		} );
 	} );
 
 	describe( 'getDocument', () => {
@@ -40,6 +47,13 @@ describe( 'TextProxy', () => {
 			expect( textProxy.getDocument() ).to.be.null;
 		} );
 
+		it( 'should return null if has no parent', () => {
+			text = new Text( 'abcdefgh' );
+			textProxy = new TextProxy( text, 1 );
+
+			expect( textProxy.getDocument() ).to.be.null;
+		} );
+
 		it( 'should return Document attached to the parent element', () => {
 			const docMock = createDocumentMock();
 			const root = new RootEditableElement( docMock, 'div' );