Procházet zdrojové kódy

Fixed tests for engine.model.Selection#focus method.

Szymon Kupś před 9 roky
rodič
revize
b40c688b2c
1 změnil soubory, kde provedl 16 přidání a 6 odebrání
  1. 16 6
      packages/ckeditor5-engine/tests/model/selection.js

+ 16 - 6
packages/ckeditor5-engine/tests/model/selection.js

@@ -249,19 +249,29 @@ describe( 'Selection', () => {
 	} );
 	} );
 
 
 	describe( 'focus', () => {
 	describe( 'focus', () => {
-		it( 'should return first end start', () => {
-			selection.addRange( range );
+		let r3;
+		beforeEach( () => {
+			const r1 = Range.createFromParentsAndOffsets( root, 2, root, 4 );
+			const r2 = Range.createFromParentsAndOffsets( root, 4, root, 6 );
+			r3 = Range.createFromParentsAndOffsets( root, 1, root, 2 );
+			selection.addRange( r1 );
+			selection.addRange( r2 );
+		} );
 
 
-			expect( selection.focus.isEqual( range.end ) ).to.be.true;
+		it( 'should return correct focus when last added range is not backward one', () => {
+			selection.addRange( r3 );
+
+			expect( selection.focus.isEqual( r3.end ) ).to.be.true;
 		} );
 		} );
 
 
-		it( 'should return first range start when backward', () => {
-			selection.addRange( range, true );
+		it( 'should return correct focus when last added range is backward one', () => {
+			selection.addRange( r3, true );
 
 
-			expect( selection.focus.isEqual( range.start ) ).to.be.true;
+			expect( selection.focus.isEqual( r3.start ) ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should return null if no ranges in selection', () => {
 		it( 'should return null if no ranges in selection', () => {
+			selection.removeAllRanges();
 			expect( selection.focus ).to.be.null;
 			expect( selection.focus ).to.be.null;
 		} );
 		} );
 	} );
 	} );