@@ -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' ) ;
@@ -75,7 +75,7 @@ describe('ReactFabric', () => {
7575 } ) ;
7676
7777 it ( 'dispatches commands on Fabric nodes with the RN renderer' , ( ) => {
78- UIManager . dispatchViewManagerCommand . mockReset ( ) ;
78+ nativeFabricUIManager . dispatchCommand . mockClear ( ) ;
7979 const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
8080 validAttributes : { title : true } ,
8181 uiViewClassName : 'RCTView' ,
@@ -84,13 +84,95 @@ describe('ReactFabric', () => {
8484 let ref = React . createRef ( ) ;
8585
8686 ReactFabric . render ( < View title = "bar" ref = { ref } /> , 11 ) ;
87- expect ( UIManager . dispatchViewManagerCommand ) . not . toBeCalled ( ) ;
87+ expect ( nativeFabricUIManager . dispatchCommand ) . not . toBeCalled ( ) ;
8888 ReactNative . dispatchCommand ( ref . current , 'myCommand' , [ 10 , 20 ] ) ;
89+ expect ( nativeFabricUIManager . dispatchCommand ) . toHaveBeenCalledTimes ( 1 ) ;
90+ expect ( nativeFabricUIManager . dispatchCommand ) . toHaveBeenCalledWith (
91+ expect . any ( Object ) ,
92+ 'myCommand' ,
93+ [ 10 , 20 ] ,
94+ ) ;
95+ expect ( UIManager . dispatchViewManagerCommand ) . not . toBeCalled ( ) ;
96+ } ) ;
97+ } ) ;
98+
99+ describe ( 'created with ReactNative called with ReactFabric' , ( ) => {
100+ beforeEach ( ( ) => {
101+ jest . resetModules ( ) ;
102+ require ( 'react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager' ) ;
103+ ReactFabric = require ( 'react-native-renderer/fabric' ) ;
104+ jest . resetModules ( ) ;
105+ UIManager = require ( 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' )
106+ . UIManager ;
107+ jest . mock ( 'shared/ReactFeatureFlags' , ( ) =>
108+ require ( 'shared/forks/ReactFeatureFlags.native-oss' ) ,
109+ ) ;
110+ ReactNative = require ( 'react-native-renderer' ) ;
111+
112+ React = require ( 'react' ) ;
113+ createReactNativeComponentClass = require ( 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' )
114+ . ReactNativeViewConfigRegistry . register ;
115+ } ) ;
116+
117+ it ( 'find Paper instances with the Fabric renderer' , ( ) => {
118+ const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
119+ validAttributes : { title : true } ,
120+ uiViewClassName : 'RCTView' ,
121+ } ) ) ;
122+
123+ let ref = React . createRef ( ) ;
124+
125+ class Component extends React . Component {
126+ render ( ) {
127+ return < View title = "foo" /> ;
128+ }
129+ }
130+
131+ ReactNative . render ( < Component ref = { ref } /> , 11 ) ;
132+
133+ let instance = ReactFabric . findHostInstance_DEPRECATED ( ref . current ) ;
134+ expect ( instance . _nativeTag ) . toBe ( 3 ) ;
135+ } ) ;
136+
137+ it ( 'find Paper nodes with the Fabric renderer' , ( ) => {
138+ const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
139+ validAttributes : { title : true } ,
140+ uiViewClassName : 'RCTView' ,
141+ } ) ) ;
142+
143+ let ref = React . createRef ( ) ;
144+
145+ class Component extends React . Component {
146+ render ( ) {
147+ return < View title = "foo" /> ;
148+ }
149+ }
150+
151+ ReactNative . render ( < Component ref = { ref } /> , 11 ) ;
152+
153+ let handle = ReactFabric . findNodeHandle ( ref . current ) ;
154+ expect ( handle ) . toBe ( 3 ) ;
155+ } ) ;
156+
157+ it ( 'dispatches commands on Paper nodes with the Fabric renderer' , ( ) => {
158+ UIManager . dispatchViewManagerCommand . mockReset ( ) ;
159+ const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
160+ validAttributes : { title : true } ,
161+ uiViewClassName : 'RCTView' ,
162+ } ) ) ;
163+
164+ let ref = React . createRef ( ) ;
165+
166+ ReactNative . render ( < View title = "bar" ref = { ref } /> , 11 ) ;
167+ expect ( UIManager . dispatchViewManagerCommand ) . not . toBeCalled ( ) ;
168+ ReactFabric . dispatchCommand ( ref . current , 'myCommand' , [ 10 , 20 ] ) ;
89169 expect ( UIManager . dispatchViewManagerCommand ) . toHaveBeenCalledTimes ( 1 ) ;
90170 expect ( UIManager . dispatchViewManagerCommand ) . toHaveBeenCalledWith (
91171 expect . any ( Number ) ,
92172 'myCommand' ,
93173 [ 10 , 20 ] ,
94174 ) ;
175+
176+ expect ( nativeFabricUIManager . dispatchCommand ) . not . toBeCalled ( ) ;
95177 } ) ;
96178} ) ;
0 commit comments