From dbe555ba78d7b0f79e482c62787db2fc3d897848 Mon Sep 17 00:00:00 2001 From: Dan Hassin Date: Thu, 12 Jan 2017 10:44:00 -0800 Subject: [PATCH] Include props in new ListView and ScrollView mocks Summary: Hi, The (as of yet unreleased) commit https://github.com/facebook/react-native/commit/5537055bf87c8b19e9fa8413486eef6a7ac5017f added some ListView and ScrollView mocks, but they leave out the original properties passed into them, which broke some of my tests (e.g. by excluding some properties like `testID`, for example, from the render tree) and I assume might break others' as well. This PR makes it so the ListView mock directly returns the scroll component (instead of wrapping it in a View), and has ListViewMock and ScrollViewMock pass their given properties through. Closes https://github.com/facebook/react-native/pull/11847 Differential Revision: D4408497 Pulled By: sahrens fbshipit-source-id: 7ec01c35d6b8efeb97761cddffdb4075d09c7d70 --- .../Components/ScrollView/__mocks__/ScrollViewMock.js | 2 +- .../CustomComponents/ListView/__mocks__/ListViewMock.js | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js b/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js index 16a62ee39a7ee7..b8e77a80770675 100644 --- a/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js +++ b/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js @@ -20,7 +20,7 @@ const RCTScrollView = requireNativeComponent('RCTScrollView'); class ScrollViewMock extends React.Component { render() { return ( - + {this.props.refreshControl} {this.props.children} diff --git a/Libraries/CustomComponents/ListView/__mocks__/ListViewMock.js b/Libraries/CustomComponents/ListView/__mocks__/ListViewMock.js index dd34d6a68c445a..a3e5e1245373a8 100644 --- a/Libraries/CustomComponents/ListView/__mocks__/ListViewMock.js +++ b/Libraries/CustomComponents/ListView/__mocks__/ListViewMock.js @@ -14,7 +14,6 @@ const ListViewDataSource = require('ListViewDataSource'); const React = require('React'); const ScrollView = require('ScrollView'); const StaticRenderer = require('StaticRenderer'); -const View = require('View'); class ListViewMock extends React.Component { static latestRef: ?ListViewMock; @@ -48,11 +47,7 @@ class ListViewMock extends React.Component { } } renderFooter && rows.push(renderFooter()); - return ( - - {this.props.renderScrollComponent({children: rows})} - - ); + return this.props.renderScrollComponent({...this.props, children: rows}); } static DataSource = ListViewDataSource; }