Skip to content

Commit 85dcaff

Browse files
committed
Merge test files
1 parent 27b2c5c commit 85dcaff

2 files changed

Lines changed: 62 additions & 79 deletions

File tree

packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let ReactNative;
1616
let UIManager;
1717
let 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,3 +75,64 @@ describe('ReactFabric', () => {
7575
expect(UIManager.dispatchViewManagerCommand).not.toBeCalled();
7676
});
7777
});
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]);
129+
expect(UIManager.dispatchViewManagerCommand).toHaveBeenCalledTimes(1);
130+
expect(UIManager.dispatchViewManagerCommand).toHaveBeenCalledWith(
131+
expect.any(Number),
132+
'myCommand',
133+
[10, 20],
134+
);
135+
136+
expect(nativeFabricUIManager.dispatchCommand).not.toBeCalled();
137+
});
138+
});

packages/react-native-renderer/src/__tests__/ReactNativeAndFabric-test.internal.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)