@@ -25,10 +25,6 @@ const SEND_ACCESSIBILITY_EVENT_REQUIRES_HOST_COMPONENT =
2525 "sendAccessibilityEvent was called with a ref that isn't a " +
2626 'native component. Use React.forwardRef to get access to the underlying native component' ;
2727
28- jest . mock ( 'shared/ReactFeatureFlags' , ( ) =>
29- require ( 'shared/forks/ReactFeatureFlags.native-oss' ) ,
30- ) ;
31-
3228describe ( 'ReactFabric' , ( ) => {
3329 beforeEach ( ( ) => {
3430 jest . resetModules ( ) ;
@@ -45,6 +41,7 @@ describe('ReactFabric', () => {
4541 act = require ( 'internal-test-utils' ) . act ;
4642 } ) ;
4743
44+ // @gate persistent
4845 it ( 'should be able to create and render a native component' , async ( ) => {
4946 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
5047 validAttributes : { foo : true } ,
@@ -59,6 +56,7 @@ describe('ReactFabric', () => {
5956 expect ( nativeFabricUIManager . completeRoot ) . toBeCalled ( ) ;
6057 } ) ;
6158
59+ // @gate persistent
6260 it ( 'should be able to create and update a native component' , async ( ) => {
6361 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
6462 validAttributes : { foo : true } ,
@@ -93,6 +91,7 @@ describe('ReactFabric', () => {
9391 } ) ;
9492 } ) ;
9593
94+ // @gate persistent
9695 it ( 'should not call FabricUIManager.cloneNode after render for properties that have not changed' , async ( ) => {
9796 const Text = createReactNativeComponentClass ( 'RCTText' , ( ) => ( {
9897 validAttributes : { foo : true } ,
@@ -164,6 +163,7 @@ describe('ReactFabric', () => {
164163 ) . toHaveBeenCalledTimes ( 1 ) ;
165164 } ) ;
166165
166+ // @gate persistent
167167 it ( 'should only pass props diffs to FabricUIManager.cloneNode' , async ( ) => {
168168 const Text = createReactNativeComponentClass ( 'RCTText' , ( ) => ( {
169169 validAttributes : { foo : true , bar : true } ,
@@ -198,9 +198,9 @@ describe('ReactFabric', () => {
198198 ) . toEqual ( {
199199 bar : 'b' ,
200200 } ) ;
201- expect (
202- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
203- ) . toMatchSnapshot ( ) ;
201+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
202+ RCTText {"foo":"a","bar":"b"}
203+ RCTRawText {"text":"1"}` ) ;
204204
205205 await act ( ( ) => {
206206 ReactFabric . render (
@@ -220,11 +220,12 @@ describe('ReactFabric', () => {
220220 ) . toEqual ( {
221221 foo : 'b' ,
222222 } ) ;
223- expect (
224- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
225- ) . toMatchSnapshot ( ) ;
223+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
224+ RCTText {"foo":"b","bar":"b"}
225+ RCTRawText {"text":"2"}` ) ;
226226 } ) ;
227227
228+ // @gate persistent
228229 it ( 'should not clone nodes without children when updating props' , async ( ) => {
229230 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
230231 validAttributes : { foo : true } ,
@@ -273,6 +274,7 @@ describe('ReactFabric', () => {
273274 expect ( nativeFabricUIManager . completeRoot ) . toBeCalled ( ) ;
274275 } ) ;
275276
277+ // @gate persistent
276278 it ( 'should call dispatchCommand for native refs' , async ( ) => {
277279 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
278280 validAttributes : { foo : true } ,
@@ -303,6 +305,7 @@ describe('ReactFabric', () => {
303305 ) ;
304306 } ) ;
305307
308+ // @gate persistent
306309 it ( 'should warn and no-op if calling dispatchCommand on non native refs' , async ( ) => {
307310 class BasicClass extends React . Component {
308311 render ( ) {
@@ -334,6 +337,7 @@ describe('ReactFabric', () => {
334337 expect ( nativeFabricUIManager . dispatchCommand ) . not . toBeCalled ( ) ;
335338 } ) ;
336339
340+ // @gate persistent
337341 it ( 'should call sendAccessibilityEvent for native refs' , async ( ) => {
338342 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
339343 validAttributes : { foo : true } ,
@@ -365,6 +369,7 @@ describe('ReactFabric', () => {
365369 ) ;
366370 } ) ;
367371
372+ // @gate persistent
368373 it ( 'should warn and no-op if calling sendAccessibilityEvent on non native refs' , async ( ) => {
369374 class BasicClass extends React . Component {
370375 render ( ) {
@@ -396,6 +401,7 @@ describe('ReactFabric', () => {
396401 expect ( nativeFabricUIManager . sendAccessibilityEvent ) . not . toBeCalled ( ) ;
397402 } ) ;
398403
404+ // @gate persistent
399405 it ( 'returns the correct instance and calls it in the callback' , ( ) => {
400406 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
401407 validAttributes : { foo : true } ,
@@ -417,6 +423,7 @@ describe('ReactFabric', () => {
417423 expect ( a ) . toBe ( c ) ;
418424 } ) ;
419425
426+ // @gate persistent
420427 it ( 'renders and reorders children' , async ( ) => {
421428 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
422429 validAttributes : { title : true } ,
@@ -425,6 +432,7 @@ describe('ReactFabric', () => {
425432
426433 class Component extends React . Component {
427434 render ( ) {
435+ // @gate persistent
428436 const chars = this . props . chars . split ( '' ) ;
429437 return (
430438 < View >
@@ -443,18 +451,57 @@ describe('ReactFabric', () => {
443451 await act ( ( ) => {
444452 ReactFabric . render ( < Component chars = { before } /> , 11 ) ;
445453 } ) ;
446- expect (
447- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
448- ) . toMatchSnapshot ( ) ;
454+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
455+ RCTView null
456+ RCTView {"title":"a"}
457+ RCTView {"title":"b"}
458+ RCTView {"title":"c"}
459+ RCTView {"title":"d"}
460+ RCTView {"title":"e"}
461+ RCTView {"title":"f"}
462+ RCTView {"title":"g"}
463+ RCTView {"title":"h"}
464+ RCTView {"title":"i"}
465+ RCTView {"title":"j"}
466+ RCTView {"title":"k"}
467+ RCTView {"title":"l"}
468+ RCTView {"title":"m"}
469+ RCTView {"title":"n"}
470+ RCTView {"title":"o"}
471+ RCTView {"title":"p"}
472+ RCTView {"title":"q"}
473+ RCTView {"title":"r"}
474+ RCTView {"title":"s"}
475+ RCTView {"title":"t"}` ) ;
449476
450477 await act ( ( ) => {
451478 ReactFabric . render ( < Component chars = { after } /> , 11 ) ;
452479 } ) ;
453- expect (
454- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
455- ) . toMatchSnapshot ( ) ;
480+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
481+ RCTView null
482+ RCTView {"title":"m"}
483+ RCTView {"title":"x"}
484+ RCTView {"title":"h"}
485+ RCTView {"title":"p"}
486+ RCTView {"title":"g"}
487+ RCTView {"title":"w"}
488+ RCTView {"title":"f"}
489+ RCTView {"title":"r"}
490+ RCTView {"title":"a"}
491+ RCTView {"title":"l"}
492+ RCTView {"title":"k"}
493+ RCTView {"title":"e"}
494+ RCTView {"title":"o"}
495+ RCTView {"title":"i"}
496+ RCTView {"title":"v"}
497+ RCTView {"title":"c"}
498+ RCTView {"title":"s"}
499+ RCTView {"title":"t"}
500+ RCTView {"title":"z"}
501+ RCTView {"title":"y"}` ) ;
456502 } ) ;
457503
504+ // @gate persistent
458505 it ( 'recreates host parents even if only children changed' , async ( ) => {
459506 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
460507 validAttributes : { title : true } ,
@@ -469,6 +516,7 @@ describe('ReactFabric', () => {
469516 chars : before ,
470517 } ;
471518 render ( ) {
519+ // @gate persistent
472520 const chars = this . state . chars . split ( '' ) ;
473521 return (
474522 < View >
@@ -490,20 +538,63 @@ describe('ReactFabric', () => {
490538 11 ,
491539 ) ;
492540 } ) ;
493- expect (
494- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
495- ) . toMatchSnapshot ( ) ;
541+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe (
542+ `11
543+ RCTView null
544+ RCTView null
545+ RCTView {"title":"a"}
546+ RCTView {"title":"b"}
547+ RCTView {"title":"c"}
548+ RCTView {"title":"d"}
549+ RCTView {"title":"e"}
550+ RCTView {"title":"f"}
551+ RCTView {"title":"g"}
552+ RCTView {"title":"h"}
553+ RCTView {"title":"i"}
554+ RCTView {"title":"j"}
555+ RCTView {"title":"k"}
556+ RCTView {"title":"l"}
557+ RCTView {"title":"m"}
558+ RCTView {"title":"n"}
559+ RCTView {"title":"o"}
560+ RCTView {"title":"p"}
561+ RCTView {"title":"q"}
562+ RCTView {"title":"r"}
563+ RCTView {"title":"s"}
564+ RCTView {"title":"t"}` ,
565+ ) ;
496566
497567 // Call setState() so that we skip over the top-level host node.
498568 // It should still get recreated despite a bailout.
499569 ref . current . setState ( {
500570 chars : after ,
501571 } ) ;
502- expect (
503- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
504- ) . toMatchSnapshot ( ) ;
572+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
573+ RCTView null
574+ RCTView null
575+ RCTView {"title":"m"}
576+ RCTView {"title":"x"}
577+ RCTView {"title":"h"}
578+ RCTView {"title":"p"}
579+ RCTView {"title":"g"}
580+ RCTView {"title":"w"}
581+ RCTView {"title":"f"}
582+ RCTView {"title":"r"}
583+ RCTView {"title":"a"}
584+ RCTView {"title":"l"}
585+ RCTView {"title":"k"}
586+ RCTView {"title":"e"}
587+ RCTView {"title":"o"}
588+ RCTView {"title":"i"}
589+ RCTView {"title":"v"}
590+ RCTView {"title":"c"}
591+ RCTView {"title":"s"}
592+ RCTView {"title":"t"}
593+ RCTView {"title":"z"}
594+ RCTView {"title":"y"}` ) ;
505595 } ) ;
506596
597+ // @gate persistent
507598 it ( 'calls setState with no arguments' , async ( ) => {
508599 let mockArgs ;
509600 class Component extends React . Component {
@@ -521,6 +612,7 @@ describe('ReactFabric', () => {
521612 expect ( mockArgs . length ) . toEqual ( 0 ) ;
522613 } ) ;
523614
615+ // @gate persistent
524616 it ( 'should call complete after inserting children' , async ( ) => {
525617 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
526618 validAttributes : { foo : true } ,
@@ -544,9 +636,13 @@ describe('ReactFabric', () => {
544636 22 ,
545637 ) ;
546638 } ) ;
547- expect ( snapshots ) . toMatchSnapshot ( ) ;
639+ expect ( snapshots ) . toEqual ( [
640+ `RCTView {"foo":"a"}
641+ RCTView {"foo":"b"}` ,
642+ ] ) ;
548643 } ) ;
549644
645+ // @gate persistent
550646 it ( 'should not throw when <View> is used inside of a <Text> ancestor' , async ( ) => {
551647 const Image = createReactNativeComponentClass ( 'RCTImage' , ( ) => ( {
552648 validAttributes : { } ,
@@ -580,6 +676,7 @@ describe('ReactFabric', () => {
580676 } ) ;
581677 } ) ;
582678
679+ // @gate persistent
583680 it ( 'should console error for text not inside of a <Text> ancestor' , async ( ) => {
584681 const ScrollView = createReactNativeComponentClass ( 'RCTScrollView' , ( ) => ( {
585682 validAttributes : { } ,
@@ -612,6 +709,7 @@ describe('ReactFabric', () => {
612709 } ) . toErrorDev ( [ 'Text strings must be rendered within a <Text> component.' ] ) ;
613710 } ) ;
614711
712+ // @gate persistent
615713 it ( 'should not throw for text inside of an indirect <Text> ancestor' , async ( ) => {
616714 const Text = createReactNativeComponentClass ( 'RCTText' , ( ) => ( {
617715 validAttributes : { } ,
@@ -630,6 +728,7 @@ describe('ReactFabric', () => {
630728 } ) ;
631729 } ) ;
632730
731+ // @gate persistent
633732 it ( 'dispatches events to the last committed props' , async ( ) => {
634733 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
635734 validAttributes : { } ,
@@ -684,6 +783,7 @@ describe('ReactFabric', () => {
684783 } ) ;
685784
686785 describe ( 'skipBubbling' , ( ) => {
786+ // @gate persistent
687787 it ( 'should skip bubbling to ancestor if specified' , async ( ) => {
688788 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
689789 validAttributes : { } ,
@@ -777,6 +877,7 @@ describe('ReactFabric', () => {
777877 } ) ;
778878 } ) ;
779879
880+ // @gate persistent
780881 it ( 'dispatches event with target as instance' , async ( ) => {
781882 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
782883 validAttributes : {
@@ -868,6 +969,7 @@ describe('ReactFabric', () => {
868969 expect . assertions ( 6 ) ;
869970 } ) ;
870971
972+ // @gate persistent
871973 it ( 'findHostInstance_DEPRECATED should warn if used to find a host component inside StrictMode' , async ( ) => {
872974 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
873975 validAttributes : { foo : true } ,
@@ -909,6 +1011,7 @@ describe('ReactFabric', () => {
9091011 expect ( match ) . toBe ( child ) ;
9101012 } ) ;
9111013
1014+ // @gate persistent
9121015 it ( 'findHostInstance_DEPRECATED should warn if passed a component that is inside StrictMode' , async ( ) => {
9131016 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
9141017 validAttributes : { foo : true } ,
@@ -948,6 +1051,7 @@ describe('ReactFabric', () => {
9481051 expect ( match ) . toBe ( child ) ;
9491052 } ) ;
9501053
1054+ // @gate persistent
9511055 it ( 'findNodeHandle should warn if used to find a host component inside StrictMode' , async ( ) => {
9521056 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
9531057 validAttributes : { foo : true } ,
@@ -989,6 +1093,7 @@ describe('ReactFabric', () => {
9891093 ) ;
9901094 } ) ;
9911095
1096+ // @gate persistent
9921097 it ( 'findNodeHandle should warn if passed a component that is inside StrictMode' , async ( ) => {
9931098 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
9941099 validAttributes : { foo : true } ,
@@ -1028,6 +1133,7 @@ describe('ReactFabric', () => {
10281133 ) ;
10291134 } ) ;
10301135
1136+ // @gate persistent
10311137 it ( 'should no-op if calling sendAccessibilityEvent on unmounted refs' , async ( ) => {
10321138 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
10331139 validAttributes : { foo : true } ,
@@ -1060,6 +1166,7 @@ describe('ReactFabric', () => {
10601166 expect ( nativeFabricUIManager . sendAccessibilityEvent ) . not . toBeCalled ( ) ;
10611167 } ) ;
10621168
1169+ // @gate persistent
10631170 it ( 'getNodeFromInternalInstanceHandle should return the correct shadow node' , async ( ) => {
10641171 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
10651172 validAttributes : { foo : true } ,
@@ -1084,6 +1191,7 @@ describe('ReactFabric', () => {
10841191 expect ( node ) . toBe ( expectedShadowNode ) ;
10851192 } ) ;
10861193
1194+ // @gate persistent
10871195 it ( 'getPublicInstanceFromInternalInstanceHandle should provide public instances for HostComponent' , async ( ) => {
10881196 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
10891197 validAttributes : { foo : true } ,
@@ -1124,6 +1232,7 @@ describe('ReactFabric', () => {
11241232 expect ( publicInstanceAfterUnmount ) . toBe ( null ) ;
11251233 } ) ;
11261234
1235+ // @gate persistent
11271236 it ( 'getPublicInstanceFromInternalInstanceHandle should provide public instances for HostText' , async ( ) => {
11281237 jest . spyOn ( ReactNativePrivateInterface , 'createPublicTextInstance' ) ;
11291238
0 commit comments