From 05b54cbee97e4e06854ed63e6fa78125b8f6ae21 Mon Sep 17 00:00:00 2001 From: Nadiia D Date: Tue, 9 Feb 2021 21:04:57 -0800 Subject: [PATCH] TextInput: create shared test utils Summary: Changelog: [General][Internal] Added some test IDs and names for the TextIput examples. Reviewed By: lunaleaps Differential Revision: D26263554 fbshipit-source-id: 958a030eafbbed9076f49ab05585f30ddef3ef23 --- .../TextInput/TextInputSharedExamples.js | 76 +++++++++++++------ 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 556a8a3a1bb..4a1f8d54e41 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -46,7 +46,6 @@ const styles = StyleSheet.create({ labelContainer: { flexDirection: 'row', marginVertical: 2, - flex: 1, }, label: { width: 115, @@ -54,6 +53,9 @@ const styles = StyleSheet.create({ marginRight: 10, paddingTop: 2, }, + inputContainer: { + flex: 1, + }, rewriteContainer: { flexDirection: 'row', alignItems: 'center', @@ -79,7 +81,7 @@ class WithLabel extends React.Component<$FlowFixMeProps> { {this.props.label} - {this.props.children} + {this.props.children} ); } @@ -335,7 +337,7 @@ class TokenizedTextExample extends React.Component< parts = parts.map(text => { if (/^#/.test(text)) { return ( - + {text} ); @@ -345,8 +347,9 @@ class TokenizedTextExample extends React.Component< }); return ( - + { @@ -416,26 +419,33 @@ class SelectionExample extends React.Component< const length = this.state.value.length; return ( - - this.setState({value})} - onSelectionChange={this.onSelectionChange.bind(this)} - ref={textInput => (this._textInput = textInput)} - selection={this.state.selection} - style={this.props.style} - value={this.state.value} - /> + + + this.setState({value})} + onSelectionChange={this.onSelectionChange.bind(this)} + ref={textInput => (this._textInput = textInput)} + selection={this.state.selection} + style={this.props.style} + value={this.state.value} + /> + - selection = {JSON.stringify(this.state.selection)} - + + selection = {JSON.stringify(this.state.selection)} + + Place at Start (0, 0) - + Place at End ({length}, {length}) Place at Random - Select All + + Select All + Select Random @@ -478,20 +488,37 @@ module.exports = ([ }, { title: 'Auto-capitalize', + name: 'autoCapitalize', render: function(): React.Node { return ( - + - + - + - + ); @@ -514,6 +541,7 @@ module.exports = ([ }, { title: 'Keyboard types', + name: 'keyboardTypes', render: function(): React.Node { const keyboardTypes = [ 'default', @@ -595,20 +623,24 @@ module.exports = ([ }, { title: 'Attributed text', + name: 'attributedText', render: function(): React.Node { return ; }, }, { title: 'Text selection & cursor placement', + name: 'cursorPlacement', render: function(): React.Node { return (