Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions scripts/fiber/tests-passing-except-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,55 @@ src/renderers/__tests__/ReactComponentTreeHook-test.js
* registers inlined text nodes
* works

src/renderers/__tests__/ReactComponentTreeHook-test.native.js
* uses displayName or Unknown for classic components
* uses displayName, name, or ReactComponent for modern components
* uses displayName, name, or Object for factory components
* uses displayName, name, or StatelessComponent for functional components
* reports a host tree correctly
* reports a simple tree with composites correctly
* reports a tree with composites correctly
* ignores null children
* ignores false children
* reports text nodes as children
* reports a single text node as a child
* reports a single number node as a child
* reports a zero as a child
* skips empty nodes for multiple children
* updates text of a single text child
* updates from no children to a single text child
* updates from a single text child to no children
* updates from no children to multiple text children
* updates from multiple text children to no children
* updates from one text child to multiple text children
* updates from multiple text children to one text child
* updates text nodes when reordering
* updates host nodes when reordering with keys
* updates host nodes when reordering with keys
* updates a single composite child of a different type
* updates a single composite child of the same type
* updates from no children to a single composite child
* updates from a single composite child to no children
* updates mixed children
* updates with a host child
* updates from null to a host child
* updates from a host child to null
* updates from a host child to a composite child
* updates from a composite child to a host child
* updates from null to a composite child
* updates from a composite child to null
* updates with a host child
* updates from null to a host child
* updates from a host child to null
* updates from a host child to a composite child
* updates from a composite child to a host child
* updates from null to a composite child
* updates from a composite child to null
* tracks owner correctly
* purges unmounted components automatically
* reports update counts
* does not report top-level wrapper as a root

src/renderers/__tests__/ReactCompositeComponent-test.js
* should warn about `forceUpdate` on unmounted components
* should warn about `setState` on unmounted components
Expand Down
49 changes: 0 additions & 49 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,55 +558,6 @@ src/renderers/__tests__/ReactComponentTreeHook-test.js
* is created during mounting
* is created when calling renderToString during render

src/renderers/__tests__/ReactComponentTreeHook-test.native.js
* uses displayName or Unknown for classic components
* uses displayName, name, or ReactComponent for modern components
* uses displayName, name, or Object for factory components
* uses displayName, name, or StatelessComponent for functional components
* reports a host tree correctly
* reports a simple tree with composites correctly
* reports a tree with composites correctly
* ignores null children
* ignores false children
* reports text nodes as children
* reports a single text node as a child
* reports a single number node as a child
* reports a zero as a child
* skips empty nodes for multiple children
* updates text of a single text child
* updates from no children to a single text child
* updates from a single text child to no children
* updates from no children to multiple text children
* updates from multiple text children to no children
* updates from one text child to multiple text children
* updates from multiple text children to one text child
* updates text nodes when reordering
* updates host nodes when reordering with keys
* updates host nodes when reordering with keys
* updates a single composite child of a different type
* updates a single composite child of the same type
* updates from no children to a single composite child
* updates from a single composite child to no children
* updates mixed children
* updates with a host child
* updates from null to a host child
* updates from a host child to null
* updates from a host child to a composite child
* updates from a composite child to a host child
* updates from null to a composite child
* updates from a composite child to null
* updates with a host child
* updates from null to a host child
* updates from a host child to null
* updates from a host child to a composite child
* updates from a composite child to a host child
* updates from null to a composite child
* updates from a composite child to null
* tracks owner correctly
* purges unmounted components automatically
* reports update counts
* does not report top-level wrapper as a root

src/renderers/__tests__/ReactCompositeComponent-test.js
* should support module pattern components
* should support rendering to different child types over time
Expand Down
7 changes: 7 additions & 0 deletions scripts/jest/test-framework-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// We want to globally mock this but jest doesn't let us do that by default
// for a file that already exists. So we have to explicitly mock it.
jest.mock('ReactDOM');
jest.mock('ReactNative');
jest.mock('ReactDOMFeatureFlags', () => {
const flags = require.requireActual('ReactDOMFeatureFlags');
return Object.assign({}, flags, {
Expand All @@ -15,6 +16,12 @@ jest.mock('ReactFeatureFlags', () => {
disableNewFiberFeatures: true,
});
});
jest.mock('ReactNativeFeatureFlags', () => {
const flags = require.requireActual('ReactNativeFeatureFlags');
return Object.assign({}, flags, {
useFiber: flags.useFiber || !!process.env.REACT_DOM_JEST_USE_FIBER,
});
});

// Error logging varies between Fiber and Stack;
// Rather than fork dozens of tests, mock the error-logging file by default.
Expand Down
6 changes: 3 additions & 3 deletions src/renderers/native/ReactNativeComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ function getTagFromInstance(inst) {
return tag;
}

function getFiberEventHandlersFromTag(tag) {
return instanceProps[tag] || null;
function getFiberCurrentPropsFromNode(stateNode) {
return instanceProps[stateNode._nativeTag] || null;
}

function updateFiberProps(tag, props) {
Expand All @@ -82,7 +82,7 @@ var ReactNativeComponentTree = {
precacheNode,
uncacheFiberNode,
uncacheNode,
getFiberCurrentPropsFromNode: getFiberEventHandlersFromTag,
getFiberCurrentPropsFromNode,
updateFiberProps,
};

Expand Down
5 changes: 5 additions & 0 deletions src/renderers/native/ReactNativeFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ const NativeRenderer = ReactFiberReconciler({
props : Props,
rootContainerInstance : Container,
) : boolean {
// Don't send a no-op message over the bridge.
if (parentInstance._children.length === 0) {
return false;
}

// Map from child objects to native tags.
// Either way we need to pass a copy of the Array to prevent it from being frozen.
const nativeTags = parentInstance._children.map(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated: There's some slow paths here that we should look into optimizing.

Expand Down
8 changes: 6 additions & 2 deletions src/renderers/native/__tests__/ReactNativeEvents-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ it('handles events', () => {
uiViewClassName: 'View',
});


var log = [];
ReactNative.render(
<View
Expand All @@ -63,7 +62,12 @@ it('handles events', () => {
);

expect(UIManager.createView.mock.calls.length).toBe(2);
var innerTag = UIManager.createView.mock.calls[1][0];

// Don't depend on the order of createView() calls.
// Stack creates views outside-in; fiber creates them inside-out.
var innerTag = UIManager.createView.mock.calls.find(
args => args[3].foo === 'inner'
)[0];

EventEmitter.receiveTouches(
'topTouchStart',
Expand Down
12 changes: 7 additions & 5 deletions src/renderers/native/__tests__/ReactNativeMount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var UIManager;

describe('ReactNative', () => {
beforeEach(() => {
jest.resetModules();

React = require('React');
ReactNative = require('ReactNative');
UIManager = require('UIManager');
Expand Down Expand Up @@ -45,17 +47,17 @@ describe('ReactNative', () => {

ReactNative.render(<View foo="foo" />, 11);

expect(UIManager.createView.mock.calls.length).toBe(2);
expect(UIManager.setChildren.mock.calls.length).toBe(2);
expect(UIManager.createView.mock.calls.length).toBe(1);
Copy link
Collaborator

@sebmarkbage sebmarkbage Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see changes to this test but no changes to how stack works. So how did this pass before vs. now? EDIT: Oh nvm. I get it. This used to be dependent on module state between resets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Noticed this when fit() running the test.

expect(UIManager.setChildren.mock.calls.length).toBe(1);
expect(UIManager.manageChildren).not.toBeCalled();
expect(UIManager.updateView).not.toBeCalled();

ReactNative.render(<View foo="bar" />, 11);

expect(UIManager.createView.mock.calls.length).toBe(2);
expect(UIManager.setChildren.mock.calls.length).toBe(2);
expect(UIManager.createView.mock.calls.length).toBe(1);
expect(UIManager.setChildren.mock.calls.length).toBe(1);
expect(UIManager.manageChildren).not.toBeCalled();
expect(UIManager.updateView).toBeCalledWith(3, 'View', { foo: 'bar' });
expect(UIManager.updateView).toBeCalledWith(2, 'View', { foo: 'bar' });
});

it('returns the correct instance and calls it in the callback', () => {
Expand Down