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;
11
11
12
12
const observers = new Map < IntersectionObserver , Item > ( ) ;
13
13
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
+ */
15
17
if (
16
18
typeof window !== "undefined" &&
17
19
typeof beforeAll !== "undefined" &&
31
33
} ) ;
32
34
}
33
35
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
+
34
53
function warnOnMissingSetup ( ) {
35
54
if ( isMocking ) return ;
36
55
console . error (
@@ -103,23 +122,6 @@ export function resetIntersectionMocking() {
103
122
observers . clear ( ) ;
104
123
}
105
124
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
-
123
125
function triggerIntersection (
124
126
elements : Element [ ] ,
125
127
trigger : boolean | number ,
You can’t perform that action at this time.
0 commit comments