Bladeren bron

Tests: Added a missing test to increase the code coverage.

Aleksander Nowodzinski 5 jaren geleden
bovenliggende
commit
c075a77837
1 gewijzigde bestanden met toevoegingen van 20 en 0 verwijderingen
  1. 20 0
      packages/ckeditor5-widget/tests/utils.js

+ 20 - 0
packages/ckeditor5-widget/tests/utils.js

@@ -591,5 +591,25 @@ describe( 'widget utils', () => {
 				name: 'arrow_n'
 			} );
 		} );
+
+		it( 'should horizontally center the balloon in the widget when the widget is completely off the viewport', () => {
+			// Widget is a 50x150 rect, translated (0,-100) from viewport's beginning (0,0).
+			const widgetRect = new Rect( {
+				top: 0,
+				left: -100,
+				right: -50,
+				bottom: 150,
+				width: 50,
+				height: 150
+			} );
+
+			const position = centeredBalloonPositionForLongWidgets( widgetRect, balloonRect );
+
+			expect( position ).to.deep.equal( {
+				top: 0 + arrowVerticalOffset,
+				left: -80,
+				name: 'arrow_n'
+			} );
+		} );
 	} );
 } );