Ver Fonte

Tests: Made the tests immune to the border-width-* styles in the test environment.

Aleksander Nowodzinski há 8 anos atrás
pai
commit
8080e17d39
1 ficheiros alterados com 24 adições e 0 exclusões
  1. 24 0
      packages/ckeditor5-utils/tests/dom/scroll.js

+ 24 - 0
packages/ckeditor5-utils/tests/dom/scroll.js

@@ -33,6 +33,14 @@ describe( 'scrollAncestorsToShowTarget()', () => {
 		secondAncestor.appendChild( firstAncestor );
 		secondAncestor.appendChild( firstAncestor );
 		firstAncestor.appendChild( element );
 		firstAncestor.appendChild( element );
 
 
+		// Make the element immune to the border-width-* styles in the test environment.
+		testUtils.sinon.stub( global.window, 'getComputedStyle', () => ( {
+			borderTopWidth: '0px',
+			borderRightWidth: '0px',
+			borderBottomWidth: '0px',
+			borderLeftWidth: '0px'
+		} ) );
+
 		stubRect( firstAncestor, {
 		stubRect( firstAncestor, {
 			top: 0, right: 100, bottom: 100, left: 0, width: 100, height: 100
 			top: 0, right: 100, bottom: 100, left: 0, width: 100, height: 100
 		}, {
 		}, {
@@ -382,6 +390,22 @@ function stubRect( target, geometryStub, scrollStub ) {
 		testUtils.sinon.stub( target, 'getClientRects' ).returns( [ geometryStub ] );
 		testUtils.sinon.stub( target, 'getClientRects' ).returns( [ geometryStub ] );
 	} else {
 	} else {
 		testUtils.sinon.stub( target, 'getBoundingClientRect' ).returns( geometryStub );
 		testUtils.sinon.stub( target, 'getBoundingClientRect' ).returns( geometryStub );
+
+		// Make the element immune to the border-width-* styles in the test environment.
+		Object.defineProperties( target, {
+			offsetWidth: {
+				value: geometryStub.width
+			},
+			clientWidth: {
+				value: geometryStub.width
+			},
+			offsetHeight: {
+				value: geometryStub.height
+			},
+			clientHeight: {
+				value: geometryStub.height
+			}
+		} );
 	}
 	}
 
 
 	if ( scrollStub ) {
 	if ( scrollStub ) {