Skip to content

Commit

Permalink
Merge test files
Browse files Browse the repository at this point in the history
  • Loading branch information
elicwhite committed Oct 29, 2019
1 parent 27b2c5c commit 85dcaff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let ReactNative;
let UIManager;
let createReactNativeComponentClass;

describe('ReactFabric', () => {
describe('created with ReactFabric called with ReactNative', () => {
beforeEach(() => {
jest.resetModules();
require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
Expand Down Expand Up @@ -75,3 +75,64 @@ describe('ReactFabric', () => {
expect(UIManager.dispatchViewManagerCommand).not.toBeCalled();
});
});

describe('created with ReactNative called with ReactFabric', () => {
beforeEach(() => {
jest.resetModules();
require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
ReactFabric = require('react-native-renderer/fabric');
jest.resetModules();
UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
.UIManager;
jest.mock('shared/ReactFeatureFlags', () =>
require('shared/forks/ReactFeatureFlags.native-oss'),
);
ReactNative = require('react-native-renderer');

React = require('react');
createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
.ReactNativeViewConfigRegistry.register;
});

it('find Paper nodes with the Fabric renderer', () => {
const View = createReactNativeComponentClass('RCTView', () => ({
validAttributes: {title: true},
uiViewClassName: 'RCTView',
}));

let ref = React.createRef();

class Component extends React.Component {
render() {
return <View title="foo" />;
}
}

ReactNative.render(<Component ref={ref} />, 11);

let handle = ReactFabric.findNodeHandle(ref.current);
expect(handle).toBe(3);
});

it('dispatches commands on Paper nodes with the Fabric renderer', () => {
UIManager.dispatchViewManagerCommand.mockReset();
const View = createReactNativeComponentClass('RCTView', () => ({
validAttributes: {title: true},
uiViewClassName: 'RCTView',
}));

let ref = React.createRef();

ReactNative.render(<View title="bar" ref={ref} />, 11);
expect(UIManager.dispatchViewManagerCommand).not.toBeCalled();
ReactFabric.dispatchCommand(ref.current, 'myCommand', [10, 20]);
expect(UIManager.dispatchViewManagerCommand).toHaveBeenCalledTimes(1);
expect(UIManager.dispatchViewManagerCommand).toHaveBeenCalledWith(
expect.any(Number),
'myCommand',
[10, 20],
);

expect(nativeFabricUIManager.dispatchCommand).not.toBeCalled();
});
});

This file was deleted.

0 comments on commit 85dcaff

Please sign in to comment.