Browse Source

Introduced a test which checks whether "Element#getNodeByPath()" works well.

Kamil Piechaczek 8 years ago
parent
commit
c6eb9e4dbf
1 changed files with 20 additions and 0 deletions
  1. 20 0
      packages/ckeditor5-engine/tests/controller/getselectedcontent.js

+ 20 - 0
packages/ckeditor5-engine/tests/controller/getselectedcontent.js

@@ -309,6 +309,26 @@ describe( 'Delete utils', () => {
 				expect( content )
 					.to.equal( '<quote><heading1>bc</heading1></quote><heading1>x</heading1><quote><heading1>de</heading1></quote>' );
 			} );
+
+			// See: https://github.com/ckeditor/ckeditor5-engine/pull/1043#issuecomment-318012286
+			it( 'ensures that elements are retrieved by indexes instead of offsets', () => {
+				doc.schema.allow( { name: '$text', inside: '$root' } );
+				doc.schema.allow( { name: '$text', inside: 'quote' } );
+
+				setData( doc,
+					'foo' +
+					'<quote>' +
+						'<paragraph>' +
+							'b[ar' +
+						'</paragraph>' +
+						'bo]m' +
+					'</quote>'
+				);
+
+				const content = stringify( getSelectedContent( doc.selection ) );
+				expect( content )
+					.to.equal( '<paragraph>ar</paragraph>bo' );
+			} );
 		} );
 	} );
 } );