@@ -26,42 +26,6 @@ describe('panelPlacement', () => {
2626 toJSON : ( ) => { } ,
2727 } ) ;
2828
29- function mockPosition ( ) {
30- // Mock `getBoundingClientRect` for elements used in the panel placement calculation
31- document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
32- mockedGetBoundingClientRect ;
33- Object . defineProperty ( document . querySelector ( '.aa-Form' ) , 'offsetLeft' , {
34- get ( ) {
35- return LEFT ;
36- } ,
37- } ) ;
38- Object . defineProperty ( document . querySelector ( '.aa-Form' ) , 'offsetTop' , {
39- get ( ) {
40- return TOP ;
41- } ,
42- } ) ;
43- document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
44- mockedGetBoundingClientRect ;
45- Object . defineProperty (
46- document . querySelector ( '.aa-Autocomplete' ) ,
47- 'offsetLeft' ,
48- {
49- get ( ) {
50- return LEFT ;
51- } ,
52- }
53- ) ;
54- Object . defineProperty (
55- document . querySelector ( '.aa-Autocomplete' ) ,
56- 'offsetTop' ,
57- {
58- get ( ) {
59- return TOP ;
60- } ,
61- }
62- ) ;
63- }
64-
6529 beforeAll ( ( ) => {
6630 Object . defineProperty ( document . documentElement , 'clientWidth' , {
6731 get ( ) {
@@ -103,7 +67,11 @@ describe('panelPlacement', () => {
10367 } ,
10468 } ) ;
10569
106- mockPosition ( ) ;
70+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
71+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
72+ mockedGetBoundingClientRect ;
73+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
74+ mockedGetBoundingClientRect ;
10775
10876 await waitFor ( ( ) => {
10977 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
@@ -127,11 +95,15 @@ describe('panelPlacement', () => {
12795
12896 fireEvent . scroll ( document . body , { target : { scrollTop : SCROLL } } ) ;
12997
130- mockPosition ( ) ;
98+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
99+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
100+ mockedGetBoundingClientRect ;
101+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
102+ mockedGetBoundingClientRect ;
131103
132104 await waitFor ( ( ) => {
133105 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
134- top : '24px ' , // TOP + HEIGHT
106+ top : '124px ' , // TOP + HEIGHT + SCROLL
135107 left : '11px' , // LEFT
136108 right : '1890px' , // CLIENT_WIDTH - (LEFT + WIDTH)
137109 width : 'unset' ,
@@ -151,7 +123,11 @@ describe('panelPlacement', () => {
151123 } ,
152124 } ) ;
153125
154- mockPosition ( ) ;
126+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
127+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
128+ mockedGetBoundingClientRect ;
129+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
130+ mockedGetBoundingClientRect ;
155131
156132 await waitFor ( ( ) => {
157133 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
@@ -172,11 +148,15 @@ describe('panelPlacement', () => {
172148
173149 fireEvent . scroll ( document . body , { target : { scrollTop : SCROLL } } ) ;
174150
175- mockPosition ( ) ;
151+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
152+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
153+ mockedGetBoundingClientRect ;
154+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
155+ mockedGetBoundingClientRect ;
176156
177157 await waitFor ( ( ) => {
178158 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
179- top : '24px ' , // TOP + HEIGHT
159+ top : '124px ' , // TOP + HEIGHT + SCROLL
180160 left : '11px' , // LEFT
181161 } ) ;
182162 } ) ;
@@ -193,7 +173,11 @@ describe('panelPlacement', () => {
193173 } ,
194174 } ) ;
195175
196- mockPosition ( ) ;
176+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
177+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
178+ mockedGetBoundingClientRect ;
179+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
180+ mockedGetBoundingClientRect ;
197181
198182 await waitFor ( ( ) => {
199183 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
@@ -214,11 +198,15 @@ describe('panelPlacement', () => {
214198
215199 fireEvent . scroll ( document . body , { target : { scrollTop : SCROLL } } ) ;
216200
217- mockPosition ( ) ;
201+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
202+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
203+ mockedGetBoundingClientRect ;
204+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
205+ mockedGetBoundingClientRect ;
218206
219207 await waitFor ( ( ) => {
220208 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
221- top : '24px ' , // TOP + HEIGHT
209+ top : '124px ' , // TOP + HEIGHT + SCROLL
222210 right : '1890px' , // CLIENT_WIDTH - (LEFT + WIDTH)
223211 } ) ;
224212 } ) ;
@@ -235,7 +223,11 @@ describe('panelPlacement', () => {
235223 } ,
236224 } ) ;
237225
238- mockPosition ( ) ;
226+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
227+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
228+ mockedGetBoundingClientRect ;
229+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
230+ mockedGetBoundingClientRect ;
239231
240232 await waitFor ( ( ) => {
241233 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
@@ -259,11 +251,15 @@ describe('panelPlacement', () => {
259251
260252 fireEvent . scroll ( document . body , { target : { scrollTop : SCROLL } } ) ;
261253
262- mockPosition ( ) ;
254+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
255+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
256+ mockedGetBoundingClientRect ;
257+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
258+ mockedGetBoundingClientRect ;
263259
264260 await waitFor ( ( ) => {
265261 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
266- top : '24px ' , // TOP + HEIGHT
262+ top : '124px ' , // TOP + HEIGHT + SCROLL
267263 left : 0 ,
268264 right : 0 ,
269265 width : 'unset' ,
@@ -281,7 +277,11 @@ describe('panelPlacement', () => {
281277 } ,
282278 } ) ;
283279
284- mockPosition ( ) ;
280+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
281+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
282+ mockedGetBoundingClientRect ;
283+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
284+ mockedGetBoundingClientRect ;
285285
286286 await waitFor ( ( ) => {
287287 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
@@ -332,11 +332,15 @@ describe('panelPlacement', () => {
332332
333333 fireEvent . scroll ( document . body , { target : { scrollTop : SCROLL } } ) ;
334334
335- mockPosition ( ) ;
335+ // Mock `getBoundingClientRect` for elements used in the panel placement calculation
336+ document . querySelector ( '.aa-Form' ) . getBoundingClientRect =
337+ mockedGetBoundingClientRect ;
338+ document . querySelector ( '.aa-Autocomplete' ) . getBoundingClientRect =
339+ mockedGetBoundingClientRect ;
336340
337341 await waitFor ( ( ) => {
338342 expect ( document . querySelector ( '.aa-Panel' ) ) . toHaveStyle ( {
339- top : '24px ' , // TOP + HEIGHT
343+ top : '124px ' , // TOP + HEIGHT + SCROLL
340344 left : '11px' , // LEFT
341345 right : '1890px' , // CLIENT_WIDTH - (LEFT + WIDTH)
342346 width : 'unset' ,
0 commit comments