File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ beforeAll(() => {
1212 : [ options . threshold ] ,
1313 root : options . root ,
1414 rootMargin : options . rootMargin ,
15+ time : Date . now ( ) ,
1516 observe : jest . fn ( ( element : Element ) => {
1617 instanceMap . set ( element , instance )
1718 observerMap . set ( element , cb )
@@ -50,12 +51,17 @@ export function mockAllIsIntersecting(isIntersecting: boolean) {
5051 */
5152export function mockIsIntersecting ( element : Element , isIntersecting : boolean ) {
5253 const cb = observerMap . get ( element )
53- if ( cb ) {
54+ const instance = instanceMap . get ( element )
55+ if ( cb && instance ) {
5456 const entry = [
5557 {
58+ boundingClientRect : element . getBoundingClientRect ( ) ,
59+ intersectionRatio : isIntersecting ? 1 : 0 ,
60+ intersectionRect : isIntersecting ? element . getBoundingClientRect ( ) : { } ,
5661 isIntersecting,
62+ rootBounds : instance . root ? instance . root . getBoundingClientRect ( ) : { } ,
5763 target : element ,
58- intersectionRatio : isIntersecting ? 1 : 0 ,
64+ time : Date . now ( ) - instance . time ,
5965 } ,
6066 ]
6167 if ( act ) act ( ( ) => cb ( entry ) )
You can’t perform that action at this time.
0 commit comments