@@ -13,13 +13,11 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1313
1414import type { HostInstance } from 'react-native' ;
1515
16- import ensureInstance from '../../../../src/private/__tests__/utilities/ensureInstance' ;
1716import * as Fantom from '@react-native/fantom' ;
1817import nullthrows from 'nullthrows' ;
1918import * as React from 'react' ;
2019import { createRef , useState } from 'react' ;
2120import { FlatList , Modal , ScrollView , View } from 'react-native' ;
22- import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement' ;
2321
2422test ( 'basic culling' , ( ) => {
2523 const root = Fantom . createRoot ( { viewportWidth : 100 , viewportHeight : 100 } ) ;
@@ -46,9 +44,7 @@ test('basic culling', () => {
4644 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
4745 ] ) ;
4846
49- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
50-
51- Fantom . scrollTo ( element , {
47+ Fantom . scrollTo ( nodeRef , {
5248 x : 0 ,
5349 y : 60 ,
5450 } ) ;
@@ -61,7 +57,7 @@ test('basic culling', () => {
6157 'Update {type: "ScrollView", nativeID: (N/A)}' ,
6258 ] ) ;
6359
64- Fantom . scrollTo ( element , {
60+ Fantom . scrollTo ( nodeRef , {
6561 x : 0 ,
6662 y : 0 ,
6763 } ) ;
@@ -118,10 +114,8 @@ test('recursive culling', () => {
118114 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
119115 ] ) ;
120116
121- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
122-
123117 // === Scroll down to the edge of child AA ===
124- Fantom . scrollTo ( element , {
118+ Fantom . scrollTo ( nodeRef , {
125119 x : 0 ,
126120 y : 30 ,
127121 } ) ;
@@ -132,7 +126,7 @@ test('recursive culling', () => {
132126
133127 // === Scroll down past child AA ===
134128
135- Fantom . scrollTo ( element , {
129+ Fantom . scrollTo ( nodeRef , {
136130 x : 0 ,
137131 y : 36 ,
138132 } ) ;
@@ -144,7 +138,7 @@ test('recursive culling', () => {
144138 ] ) ;
145139
146140 // === Scroll down past child AB ===
147- Fantom . scrollTo ( element , {
141+ Fantom . scrollTo ( nodeRef , {
148142 x : 0 ,
149143 y : 51 ,
150144 } ) ;
@@ -156,7 +150,7 @@ test('recursive culling', () => {
156150 ] ) ;
157151
158152 // === Scroll down past element A ===
159- Fantom . scrollTo ( element , {
153+ Fantom . scrollTo ( nodeRef , {
160154 x : 0 ,
161155 y : 56 ,
162156 } ) ;
@@ -168,7 +162,7 @@ test('recursive culling', () => {
168162 ] ) ;
169163
170164 // Scroll element B into viewport. Just child BA should be created.
171- Fantom . scrollTo ( element , {
165+ Fantom . scrollTo ( nodeRef , {
172166 x : 0 ,
173167 y : 155 ,
174168 } ) ;
@@ -182,7 +176,7 @@ test('recursive culling', () => {
182176 ] ) ;
183177
184178 // Scroll child BA into viewport.
185- Fantom . scrollTo ( element , {
179+ Fantom . scrollTo ( nodeRef , {
186180 x : 0 ,
187181 y : 165 ,
188182 } ) ;
@@ -194,7 +188,7 @@ test('recursive culling', () => {
194188 ] ) ;
195189
196190 // Scroll back to start
197- Fantom . scrollTo ( element , {
191+ Fantom . scrollTo ( nodeRef , {
198192 x : 0 ,
199193 y : 0 ,
200194 } ) ;
@@ -216,7 +210,7 @@ test('recursive culling', () => {
216210 ] ) ;
217211
218212 // Scroll past element A
219- Fantom . scrollTo ( element , {
213+ Fantom . scrollTo ( nodeRef , {
220214 x : 0 ,
221215 y : 85 ,
222216 } ) ;
@@ -265,9 +259,7 @@ test('recursive culling when initial offset is negative', () => {
265259 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
266260 ] ) ;
267261
268- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
269-
270- Fantom . scrollTo ( element , {
262+ Fantom . scrollTo ( nodeRef , {
271263 x : 0 ,
272264 y : 0 ,
273265 } ) ;
@@ -328,9 +320,7 @@ test('deep nesting', () => {
328320 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
329321 ] ) ;
330322
331- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
332-
333- Fantom . scrollTo ( element , {
323+ Fantom . scrollTo ( nodeRef , {
334324 x : 0 ,
335325 y : 40 ,
336326 } ) ;
@@ -345,7 +335,7 @@ test('deep nesting', () => {
345335 'Insert {type: "View", parentNativeID: (N/A), index: 1, nativeID: "element B"}' ,
346336 ] ) ;
347337
348- Fantom . scrollTo ( element , {
338+ Fantom . scrollTo ( nodeRef , {
349339 x : 0 ,
350340 y : 150 ,
351341 } ) ;
@@ -489,9 +479,7 @@ test('initial render', () => {
489479 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
490480 ] ) ;
491481
492- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
493-
494- Fantom . scrollTo ( element , {
482+ Fantom . scrollTo ( nodeRef , {
495483 x : 0 ,
496484 y : 100 ,
497485 } ) ;
@@ -561,9 +549,7 @@ test('basic culling smaller ScrollView', () => {
561549 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
562550 ] ) ;
563551
564- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
565-
566- Fantom . scrollTo ( element , {
552+ Fantom . scrollTo ( nodeRef , {
567553 x : 0 ,
568554 y : 11 ,
569555 } ) ;
@@ -624,9 +610,7 @@ test('culling with transform move', () => {
624610 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
625611 ] ) ;
626612
627- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
628-
629- Fantom . scrollTo ( element , {
613+ Fantom . scrollTo ( nodeRef , {
630614 x : 0 ,
631615 y : 1 ,
632616 } ) ;
@@ -669,9 +653,7 @@ test('culling with recursive transform move', () => {
669653 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
670654 ] ) ;
671655
672- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
673-
674- Fantom . scrollTo ( element , {
656+ Fantom . scrollTo ( nodeRef , {
675657 x : 0 ,
676658 y : 1 ,
677659 } ) ;
@@ -713,9 +695,7 @@ test('culling with transform scale', () => {
713695 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
714696 ] ) ;
715697
716- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
717-
718- Fantom . scrollTo ( element , {
698+ Fantom . scrollTo ( nodeRef , {
719699 x : 0 ,
720700 y : 121 ,
721701 } ) ;
@@ -774,10 +754,8 @@ test('culling inside of Modal', () => {
774754 ) ;
775755 } ) ;
776756
777- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
778-
779757 Fantom . runOnUIThread ( ( ) => {
780- Fantom . enqueueModalSizeUpdate ( element , {
758+ Fantom . enqueueModalSizeUpdate ( nodeRef , {
781759 width : 100 ,
782760 height : 100 ,
783761 } ) ;
@@ -900,9 +878,7 @@ describe('reparenting', () => {
900878 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}' ,
901879 ] ) ;
902880
903- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
904-
905- Fantom . scrollTo ( element , {
881+ Fantom . scrollTo ( nodeRef , {
906882 x : 0 ,
907883 y : 60 ,
908884 } ) ;
@@ -1578,10 +1554,8 @@ describe('reparenting', () => {
15781554 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}' ,
15791555 ] ) ;
15801556
1581- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
1582-
15831557 // Scroll down to see the grandchild.
1584- Fantom . scrollTo ( element , {
1558+ Fantom . scrollTo ( nodeRef , {
15851559 x : 0 ,
15861560 y : 115 ,
15871561 } ) ;
@@ -1669,10 +1643,8 @@ describe('reparenting', () => {
16691643 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}' ,
16701644 ] ) ;
16711645
1672- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
1673-
16741646 // Scroll down to see the grandchild.
1675- Fantom . scrollTo ( element , {
1647+ Fantom . scrollTo ( nodeRef , {
16761648 x : 0 ,
16771649 y : 118 ,
16781650 } ) ;
@@ -1911,10 +1883,8 @@ describe('reparenting', () => {
19111883 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}' ,
19121884 ] ) ;
19131885
1914- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
1915-
19161886 // Scroll to reveal grandchild.
1917- Fantom . scrollTo ( element , {
1887+ Fantom . scrollTo ( nodeRef , {
19181888 x : 0 ,
19191889 y : 70 ,
19201890 } ) ;
@@ -2001,10 +1971,8 @@ describe('reparenting', () => {
20011971 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}' ,
20021972 ] ) ;
20031973
2004- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
2005-
20061974 // Scroll to reveal grandchild.
2007- Fantom . scrollTo ( element , {
1975+ Fantom . scrollTo ( nodeRef , {
20081976 x : 0 ,
20091977 y : 70 ,
20101978 } ) ;
@@ -2214,9 +2182,7 @@ describe('reparenting', () => {
22142182 'Insert {type: "View", parentNativeID: "unflattened", index: 0, nativeID: "child"}' ,
22152183 ] ) ;
22162184
2217- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
2218-
2219- Fantom . scrollTo ( element , {
2185+ Fantom . scrollTo ( nodeRef , {
22202186 x : 0 ,
22212187 y : 50 ,
22222188 } ) ;
@@ -2312,9 +2278,7 @@ describe('reparenting', () => {
23122278 'Insert {type: "View", parentNativeID: "unflattened", index: 0, nativeID: "child"}' ,
23132279 ] ) ;
23142280
2315- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
2316-
2317- Fantom . scrollTo ( element , {
2281+ Fantom . scrollTo ( nodeRef , {
23182282 x : 0 ,
23192283 y : 50 ,
23202284 } ) ;
@@ -2463,10 +2427,9 @@ describe('opt out mechanism - Unstable_uncullableView & Unstable_uncullableTrace
24632427 </ ScrollView > ,
24642428 ) ;
24652429 } ) ;
2466- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
24672430
24682431 Fantom . runOnUIThread ( ( ) => {
2469- Fantom . enqueueModalSizeUpdate ( element , {
2432+ Fantom . enqueueModalSizeUpdate ( nodeRef , {
24702433 width : 100 ,
24712434 height : 100 ,
24722435 } ) ;
@@ -2517,10 +2480,8 @@ describe('opt out mechanism - Unstable_uncullableView & Unstable_uncullableTrace
25172480 ) ;
25182481 } ) ;
25192482
2520- const element = ensureInstance ( nodeRef . current , ReactNativeElement ) ;
2521-
25222483 Fantom . runOnUIThread ( ( ) => {
2523- Fantom . enqueueModalSizeUpdate ( element , {
2484+ Fantom . enqueueModalSizeUpdate ( nodeRef , {
25242485 width : 100 ,
25252486 height : 100 ,
25262487 } ) ;
0 commit comments