8
0
Kamil Piechaczek 8 лет назад
Родитель
Сommit
15eed8847e

+ 1 - 1
packages/ckeditor5-engine/tests/model/position.js

@@ -867,7 +867,7 @@ describe( 'Position', () => {
 			test( fPosition, zPosition, li1 );
 		} );
 
-		it( 'for two different positions returns first element which contains both positions', () => {
+		it( 'works when one positions is nested deeper than the other', () => {
 			const zPosition = new Position( root, [ 1, 0, 2 ] );
 			const liPosition = new Position( root, [ 1, 1 ] );
 

+ 18 - 14
packages/ckeditor5-engine/tests/view/position.js

@@ -521,7 +521,7 @@ describe( 'Position', () => {
 	} );
 
 	describe( 'getCommonAncestor()', () => {
-		let div, p, ul, li1, li2, foz, bar, ipsum;
+		let div, section, article, p, ul, li1, li2, foz, bar, lipsum;
 
 		// |- div
 		//   |- ul
@@ -533,25 +533,29 @@ describe( 'Position', () => {
 		//   |     |- b
 		//   |     |- a
 		//   |     |- r
-		//   |- p
-		//     |- i
-		//     |- p
-		//     |- s
-		//     |- u
-		//     |- m
+		//   |- section
+		//     |- article
+		//       |- p
+		//         |- l
+		//         |- i
+		//         |- p
+		//         |- s
+		//         |- u
+		//         |- m
 
 		beforeEach( () => {
 			foz = new Text( 'foz' );
 			bar = new Text( 'bar' );
-			ipsum = new Text( 'ipsum' );
-
 			li1 = new Element( 'li', null, foz );
 			li2 = new Element( 'li', null, bar );
+			ul = new Element( 'ul', null, [ li1, li2 ] );
 
-			p = new Element( 'p', null, ipsum );
+			lipsum = new Text( 'lipsum' );
+			p = new Element( 'p', null, lipsum );
+			article = new Element( 'article', null, p );
+			section = new Element( 'section', null, article );
 
-			ul = new Element( 'ul', null, [ li1, li2 ] );
-			div = new Element( 'div', null, [ ul, p ] );
+			div = new Element( 'div', null, [ ul, section ] );
 		} );
 
 		it( 'for two the same positions returns the parent element', () => {
@@ -568,9 +572,9 @@ describe( 'Position', () => {
 			test( fPosition, zPosition, li1 );
 		} );
 
-		it( 'for two different positions returns first element which contains both positions', () => {
+		it( 'works when one positions is nested deeper than the other', () => {
 			const zPosition = new Position( li1, 2 );
-			const iPosition = Position.createAt( ipsum, 'start' );
+			const iPosition = Position.createAt( lipsum, 'start' );
 
 			test( iPosition, zPosition, div );
 		} );