@@ -25,14 +25,13 @@ 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 ( ) ;
3531
32+ // TODO: migrate these tests off of the legacy API
33+ require ( 'shared/ReactFeatureFlags' ) . disableLegacyMode = false ;
34+
3635 require ( 'react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager' ) ;
3736
3837 React = require ( 'react' ) ;
@@ -198,9 +197,9 @@ describe('ReactFabric', () => {
198197 ) . toEqual ( {
199198 bar : 'b' ,
200199 } ) ;
201- expect (
202- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
203- ) . toMatchSnapshot ( ) ;
200+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
201+ RCTText {"foo":"a","bar":"b"}
202+ RCTRawText {"text":"1"}` ) ;
204203
205204 await act ( ( ) => {
206205 ReactFabric . render (
@@ -220,9 +219,9 @@ describe('ReactFabric', () => {
220219 ) . toEqual ( {
221220 foo : 'b' ,
222221 } ) ;
223- expect (
224- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
225- ) . toMatchSnapshot ( ) ;
222+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
223+ RCTText {"foo":"b","bar":"b"}
224+ RCTRawText {"text":"2"}` ) ;
226225 } ) ;
227226
228227 it ( 'should not clone nodes without children when updating props' , async ( ) => {
@@ -443,16 +442,54 @@ describe('ReactFabric', () => {
443442 await act ( ( ) => {
444443 ReactFabric . render ( < Component chars = { before } /> , 11 ) ;
445444 } ) ;
446- expect (
447- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
448- ) . toMatchSnapshot ( ) ;
445+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
446+ RCTView null
447+ RCTView {"title":"a"}
448+ RCTView {"title":"b"}
449+ RCTView {"title":"c"}
450+ RCTView {"title":"d"}
451+ RCTView {"title":"e"}
452+ RCTView {"title":"f"}
453+ RCTView {"title":"g"}
454+ RCTView {"title":"h"}
455+ RCTView {"title":"i"}
456+ RCTView {"title":"j"}
457+ RCTView {"title":"k"}
458+ RCTView {"title":"l"}
459+ RCTView {"title":"m"}
460+ RCTView {"title":"n"}
461+ RCTView {"title":"o"}
462+ RCTView {"title":"p"}
463+ RCTView {"title":"q"}
464+ RCTView {"title":"r"}
465+ RCTView {"title":"s"}
466+ RCTView {"title":"t"}` ) ;
449467
450468 await act ( ( ) => {
451469 ReactFabric . render ( < Component chars = { after } /> , 11 ) ;
452470 } ) ;
453- expect (
454- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
455- ) . toMatchSnapshot ( ) ;
471+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
472+ RCTView null
473+ RCTView {"title":"m"}
474+ RCTView {"title":"x"}
475+ RCTView {"title":"h"}
476+ RCTView {"title":"p"}
477+ RCTView {"title":"g"}
478+ RCTView {"title":"w"}
479+ RCTView {"title":"f"}
480+ RCTView {"title":"r"}
481+ RCTView {"title":"a"}
482+ RCTView {"title":"l"}
483+ RCTView {"title":"k"}
484+ RCTView {"title":"e"}
485+ RCTView {"title":"o"}
486+ RCTView {"title":"i"}
487+ RCTView {"title":"v"}
488+ RCTView {"title":"c"}
489+ RCTView {"title":"s"}
490+ RCTView {"title":"t"}
491+ RCTView {"title":"z"}
492+ RCTView {"title":"y"}` ) ;
456493 } ) ;
457494
458495 it ( 'recreates host parents even if only children changed' , async ( ) => {
@@ -490,18 +527,60 @@ describe('ReactFabric', () => {
490527 11 ,
491528 ) ;
492529 } ) ;
493- expect (
494- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
495- ) . toMatchSnapshot ( ) ;
530+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe (
531+ `11
532+ RCTView null
533+ RCTView null
534+ RCTView {"title":"a"}
535+ RCTView {"title":"b"}
536+ RCTView {"title":"c"}
537+ RCTView {"title":"d"}
538+ RCTView {"title":"e"}
539+ RCTView {"title":"f"}
540+ RCTView {"title":"g"}
541+ RCTView {"title":"h"}
542+ RCTView {"title":"i"}
543+ RCTView {"title":"j"}
544+ RCTView {"title":"k"}
545+ RCTView {"title":"l"}
546+ RCTView {"title":"m"}
547+ RCTView {"title":"n"}
548+ RCTView {"title":"o"}
549+ RCTView {"title":"p"}
550+ RCTView {"title":"q"}
551+ RCTView {"title":"r"}
552+ RCTView {"title":"s"}
553+ RCTView {"title":"t"}` ,
554+ ) ;
496555
497556 // Call setState() so that we skip over the top-level host node.
498557 // It should still get recreated despite a bailout.
499558 ref . current . setState ( {
500559 chars : after ,
501560 } ) ;
502- expect (
503- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
504- ) . toMatchSnapshot ( ) ;
561+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
562+ RCTView null
563+ RCTView null
564+ RCTView {"title":"m"}
565+ RCTView {"title":"x"}
566+ RCTView {"title":"h"}
567+ RCTView {"title":"p"}
568+ RCTView {"title":"g"}
569+ RCTView {"title":"w"}
570+ RCTView {"title":"f"}
571+ RCTView {"title":"r"}
572+ RCTView {"title":"a"}
573+ RCTView {"title":"l"}
574+ RCTView {"title":"k"}
575+ RCTView {"title":"e"}
576+ RCTView {"title":"o"}
577+ RCTView {"title":"i"}
578+ RCTView {"title":"v"}
579+ RCTView {"title":"c"}
580+ RCTView {"title":"s"}
581+ RCTView {"title":"t"}
582+ RCTView {"title":"z"}
583+ RCTView {"title":"y"}` ) ;
505584 } ) ;
506585
507586 it ( 'calls setState with no arguments' , async ( ) => {
@@ -544,7 +623,10 @@ describe('ReactFabric', () => {
544623 22 ,
545624 ) ;
546625 } ) ;
547- expect ( snapshots ) . toMatchSnapshot ( ) ;
626+ expect ( snapshots ) . toEqual ( [
627+ `RCTView {"foo":"a"}
628+ RCTView {"foo":"b"}` ,
629+ ] ) ;
548630 } ) ;
549631
550632 it ( 'should not throw when <View> is used inside of a <Text> ancestor' , async ( ) => {
0 commit comments