File tree Expand file tree Collapse file tree 1 file changed +20
-18
lines changed Expand file tree Collapse file tree 1 file changed +20
-18
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ let isMocking = false;
1111
1212const observers = new Map < IntersectionObserver , Item > ( ) ;
1313
14- // If we are running in a valid testing environment, we can mock the IntersectionObserver.
14+ /*
15+ ** If we are running in a valid testing environment, we can automate mocking the IntersectionObserver.
16+ */
1517if (
1618 typeof window !== "undefined" &&
1719 typeof beforeAll !== "undefined" &&
3133 } ) ;
3234}
3335
36+ function getActFn ( ) {
37+ if (
38+ ! (
39+ typeof window !== "undefined" &&
40+ // @ts -ignore
41+ window . IS_REACT_ACT_ENVIRONMENT
42+ )
43+ ) {
44+ return undefined ;
45+ }
46+
47+ return typeof React . act === "function"
48+ ? // @ts -ignore - Older versions of React don't have the `act` method, so TypeScript will complain about it
49+ React . act
50+ : DeprecatedReactTestUtils . act ;
51+ }
52+
3453function warnOnMissingSetup ( ) {
3554 if ( isMocking ) return ;
3655 console . error (
@@ -103,23 +122,6 @@ export function resetIntersectionMocking() {
103122 observers . clear ( ) ;
104123}
105124
106- function getActFn ( ) {
107- if (
108- ! (
109- typeof window !== "undefined" &&
110- // @ts -ignore
111- window . IS_REACT_ACT_ENVIRONMENT
112- )
113- ) {
114- return undefined ;
115- }
116-
117- // @ts -ignore - Older versions of React don't have the `act` method, so TypeScript will complain about it
118- return typeof React . act === "function"
119- ? React . act
120- : DeprecatedReactTestUtils . act ;
121- }
122-
123125function triggerIntersection (
124126 elements : Element [ ] ,
125127 trigger : boolean | number ,
You can’t perform that action at this time.
0 commit comments