File tree Expand file tree Collapse file tree 2 files changed +11
-19
lines changed Expand file tree Collapse file tree 2 files changed +11
-19
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ export class Helper {
6363 div . style . height = `${ this . targetSize . height } px` ;
6464 div . style . width = `${ this . targetSize . width } px` ;
6565 div . style . position = 'absolute' ;
66+ div . style . display = 'none' ;
6667 document . body . insertAdjacentElement ( 'beforeend' , div ) ;
6768 }
6869
@@ -212,16 +213,17 @@ export class Helper {
212213
213214 targetEl ! . getBoundingClientRect = jest . fn ( ( ) => {
214215 const top = 0 ,
215- left = 0 ;
216+ left = 0 ,
217+ hiddenSize = targetEl ?. style . display === 'none' ? 0 : null ;
216218
217219 return {
218220 x : left ,
219221 y : top ,
220- width : this . targetSize . width ,
221- height : this . targetSize . height ,
222+ width : hiddenSize ?? this . targetSize . width ,
223+ height : hiddenSize ?? this . targetSize . height ,
222224 top : top ,
223- right : left + this . targetSize . width ,
224- bottom : top + this . targetSize . height ,
225+ right : left + ( hiddenSize ?? this . targetSize . width ) ,
226+ bottom : top + ( hiddenSize ?? this . targetSize . height ) ,
225227 left : left ,
226228 toJSON : ( ) => '{}' ,
227229 } ;
Original file line number Diff line number Diff line change @@ -24,8 +24,7 @@ const windowSize: SizeData = {
2424 'bottom center' ,
2525 'bottom right' ,
2626 ] ,
27- helper = new Helper ( CollisionHandler . ignore , anchorSize , targetSize ) ,
28- collisionHandler : ( input : number ) => number = ( input ) => input + 50 ;
27+ helper = new Helper ( CollisionHandler . ignore , anchorSize , targetSize ) ;
2928
3029helper . setupEnvironment ( windowSize ) ;
3130
@@ -86,18 +85,9 @@ test('Window scroll adjusts output', () => {
8685 left : parseInt ( pData . left , 10 ) ,
8786 top : parseInt ( pData . top , 10 ) ,
8887 } ) . toStrictEqual ( {
89- left : helper . getLeft (
90- targetWindowPosition ,
91- myPlacement ,
92- atPlacement ,
93- collisionHandler ,
94- ) ,
95- top : helper . getTop (
96- targetWindowPosition ,
97- myPlacement ,
98- atPlacement ,
99- collisionHandler ,
100- ) ,
88+ left :
89+ helper . getLeft ( targetWindowPosition , myPlacement , atPlacement ) + 50 ,
90+ top : helper . getTop ( targetWindowPosition , myPlacement , atPlacement ) + 50 ,
10191 } ) ;
10292
10393 // Reset the window scroll position
You can’t perform that action at this time.
0 commit comments