@@ -25,14 +25,13 @@ const SEND_ACCESSIBILITY_EVENT_REQUIRES_HOST_COMPONENT =
25
25
"sendAccessibilityEvent was called with a ref that isn't a " +
26
26
'native component. Use React.forwardRef to get access to the underlying native component' ;
27
27
28
- jest . mock ( 'shared/ReactFeatureFlags' , ( ) =>
29
- require ( 'shared/forks/ReactFeatureFlags.native-oss' ) ,
30
- ) ;
31
-
32
28
describe ( 'ReactFabric' , ( ) => {
33
29
beforeEach ( ( ) => {
34
30
jest . resetModules ( ) ;
35
31
32
+ // TODO: migrate these tests off of the legacy API
33
+ require ( 'shared/ReactFeatureFlags' ) . disableLegacyMode = false ;
34
+
36
35
require ( 'react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager' ) ;
37
36
38
37
React = require ( 'react' ) ;
@@ -198,9 +197,9 @@ describe('ReactFabric', () => {
198
197
) . toEqual ( {
199
198
bar : 'b' ,
200
199
} ) ;
201
- expect (
202
- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
203
- ) . toMatchSnapshot ( ) ;
200
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
201
+ RCTText {"foo":"a","bar":"b"}
202
+ RCTRawText {"text":"1"}` ) ;
204
203
205
204
await act ( ( ) => {
206
205
ReactFabric . render (
@@ -220,9 +219,9 @@ describe('ReactFabric', () => {
220
219
) . toEqual ( {
221
220
foo : 'b' ,
222
221
} ) ;
223
- expect (
224
- nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ,
225
- ) . toMatchSnapshot ( ) ;
222
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toBe ( `11
223
+ RCTText {"foo":"b","bar":"b"}
224
+ RCTRawText {"text":"2"}` ) ;
226
225
} ) ;
227
226
228
227
it ( 'should not clone nodes without children when updating props' , async ( ) => {
@@ -443,16 +442,54 @@ describe('ReactFabric', () => {
443
442
await act ( ( ) => {
444
443
ReactFabric . render ( < Component chars = { before } /> , 11 ) ;
445
444
} ) ;
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"}` ) ;
449
467
450
468
await act ( ( ) => {
451
469
ReactFabric . render ( < Component chars = { after } /> , 11 ) ;
452
470
} ) ;
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"}` ) ;
456
493
} ) ;
457
494
458
495
it ( 'recreates host parents even if only children changed' , async ( ) => {
@@ -490,18 +527,60 @@ describe('ReactFabric', () => {
490
527
11 ,
491
528
) ;
492
529
} ) ;
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
+ ) ;
496
555
497
556
// Call setState() so that we skip over the top-level host node.
498
557
// It should still get recreated despite a bailout.
499
558
ref . current . setState ( {
500
559
chars : after ,
501
560
} ) ;
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"}` ) ;
505
584
} ) ;
506
585
507
586
it ( 'calls setState with no arguments' , async ( ) => {
@@ -544,7 +623,10 @@ describe('ReactFabric', () => {
544
623
22 ,
545
624
) ;
546
625
} ) ;
547
- expect ( snapshots ) . toMatchSnapshot ( ) ;
626
+ expect ( snapshots ) . toEqual ( [
627
+ `RCTView {"foo":"a"}
628
+ RCTView {"foo":"b"}` ,
629
+ ] ) ;
548
630
} ) ;
549
631
550
632
it ( 'should not throw when <View> is used inside of a <Text> ancestor' , async ( ) => {
0 commit comments