@@ -16,7 +16,7 @@ let ReactNative;
1616let UIManager ;
1717let createReactNativeComponentClass ;
1818
19- describe ( 'ReactFabric' , ( ) => {
19+ describe ( 'created with ReactFabric called with ReactNative ' , ( ) => {
2020 beforeEach ( ( ) => {
2121 jest . resetModules ( ) ;
2222 require ( 'react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager' ) ;
@@ -55,7 +55,7 @@ describe('ReactFabric', () => {
5555 } ) ;
5656
5757 it ( 'dispatches commands on Fabric nodes with the RN renderer' , ( ) => {
58- UIManager . dispatchViewManagerCommand . mockReset ( ) ;
58+ nativeFabricUIManager . dispatchCommand . mockClear ( ) ;
5959 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
6060 validAttributes : { title : true } ,
6161 uiViewClassName : 'RCTView' ,
@@ -64,13 +64,75 @@ describe('ReactFabric', () => {
6464 let ref = React . createRef ( ) ;
6565
6666 ReactFabric . render ( < View title = "bar" ref = { ref } /> , 11 ) ;
67- expect ( UIManager . dispatchViewManagerCommand ) . not . toBeCalled ( ) ;
67+ expect ( nativeFabricUIManager . dispatchCommand ) . not . toBeCalled ( ) ;
6868 ReactNative . dispatchCommand ( ref . current , 'myCommand' , [ 10 , 20 ] ) ;
69+ expect ( nativeFabricUIManager . dispatchCommand ) . toHaveBeenCalledTimes ( 1 ) ;
70+ expect ( nativeFabricUIManager . dispatchCommand ) . toHaveBeenCalledWith (
71+ expect . any ( Object ) ,
72+ 'myCommand' ,
73+ [ 10 , 20 ] ,
74+ ) ;
75+ expect ( UIManager . dispatchViewManagerCommand ) . not . toBeCalled ( ) ;
76+ } ) ;
77+ } ) ;
78+
79+ describe ( 'created with ReactNative called with ReactFabric' , ( ) => {
80+ beforeEach ( ( ) => {
81+ jest . resetModules ( ) ;
82+ require ( 'react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager' ) ;
83+ ReactFabric = require ( 'react-native-renderer/fabric' ) ;
84+ jest . resetModules ( ) ;
85+ UIManager = require ( 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' )
86+ . UIManager ;
87+ jest . mock ( 'shared/ReactFeatureFlags' , ( ) =>
88+ require ( 'shared/forks/ReactFeatureFlags.native-oss' ) ,
89+ ) ;
90+ ReactNative = require ( 'react-native-renderer' ) ;
91+
92+ React = require ( 'react' ) ;
93+ createReactNativeComponentClass = require ( 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' )
94+ . ReactNativeViewConfigRegistry . register ;
95+ } ) ;
96+
97+ it ( 'find Paper nodes with the Fabric renderer' , ( ) => {
98+ const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
99+ validAttributes : { title : true } ,
100+ uiViewClassName : 'RCTView' ,
101+ } ) ) ;
102+
103+ let ref = React . createRef ( ) ;
104+
105+ class Component extends React . Component {
106+ render ( ) {
107+ return < View title = "foo" /> ;
108+ }
109+ }
110+
111+ ReactNative . render ( < Component ref = { ref } /> , 11 ) ;
112+
113+ let handle = ReactFabric . findNodeHandle ( ref . current ) ;
114+ expect ( handle ) . toBe ( 3 ) ;
115+ } ) ;
116+
117+ it ( 'dispatches commands on Paper nodes with the Fabric renderer' , ( ) => {
118+ UIManager . dispatchViewManagerCommand . mockReset ( ) ;
119+ const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
120+ validAttributes : { title : true } ,
121+ uiViewClassName : 'RCTView' ,
122+ } ) ) ;
123+
124+ let ref = React . createRef ( ) ;
125+
126+ ReactNative . render ( < View title = "bar" ref = { ref } /> , 11 ) ;
127+ expect ( UIManager . dispatchViewManagerCommand ) . not . toBeCalled ( ) ;
128+ ReactFabric . dispatchCommand ( ref . current , 'myCommand' , [ 10 , 20 ] ) ;
69129 expect ( UIManager . dispatchViewManagerCommand ) . toHaveBeenCalledTimes ( 1 ) ;
70130 expect ( UIManager . dispatchViewManagerCommand ) . toHaveBeenCalledWith (
71131 expect . any ( Number ) ,
72132 'myCommand' ,
73133 [ 10 , 20 ] ,
74134 ) ;
135+
136+ expect ( nativeFabricUIManager . dispatchCommand ) . not . toBeCalled ( ) ;
75137 } ) ;
76138} ) ;
0 commit comments