@@ -970,7 +970,7 @@ it('applies RTL text alignment and writing direction to the TextInput (outlined)
970970 } ) ;
971971} ) ;
972972
973- it ( 'applies RTL writing direction to supporting text' , async ( ) => {
973+ it ( 'applies RTL writing direction and start alignment to supporting text on native ' , async ( ) => {
974974 I18nManager . isRTL = true ;
975975
976976 await render (
@@ -983,11 +983,88 @@ it('applies RTL writing direction to supporting text', async () => {
983983 ) ;
984984
985985 expect ( screen . getByText ( 'Hint' , includeHiddenElements ) ) . toHaveStyle ( {
986+ textAlign : 'left' ,
987+ writingDirection : 'rtl' ,
988+ } ) ;
989+ } ) ;
990+
991+ it ( 'aligns the counter to the end side in RTL on native' , async ( ) => {
992+ I18nManager . isRTL = true ;
993+
994+ await render (
995+ < TextInput
996+ label = "Email"
997+ value = "ab"
998+ maxLength = { 10 }
999+ counter
1000+ onChangeText = { ( ) => { } }
1001+ />
1002+ ) ;
1003+
1004+ expect ( screen . getByText ( '2/10' , includeHiddenElements ) ) . toHaveStyle ( {
1005+ textAlign : 'right' ,
9861006 writingDirection : 'rtl' ,
9871007 } ) ;
9881008} ) ;
9891009
990- it ( 'places EndAccessory before StartAccessory in the tree when RTL' , async ( ) => {
1010+ it ( 'places the label on the right side when RTL' , async ( ) => {
1011+ I18nManager . isRTL = true ;
1012+
1013+ await render ( < TextInput label = "Email" value = "" onChangeText = { ( ) => { } } /> ) ;
1014+
1015+ const labelStyle = StyleSheet . flatten (
1016+ // eslint-disable-next-line no-restricted-syntax -- label wrapper has no accessible handle.
1017+ screen . getByText ( 'Email' , includeHiddenElements ) . parent ?. props . style
1018+ ) ;
1019+ expect ( labelStyle ) . toHaveProperty ( 'start' ) ;
1020+ } ) ;
1021+
1022+ it ( 'places the helper on the right side when RTL' , async ( ) => {
1023+ I18nManager . isRTL = true ;
1024+
1025+ await render (
1026+ < TextInput
1027+ label = "Email"
1028+ value = ""
1029+ supportingText = "Helper"
1030+ onChangeText = { ( ) => { } }
1031+ />
1032+ ) ;
1033+
1034+ expect ( screen . getByText ( 'Helper' , includeHiddenElements ) ) . toHaveStyle ( {
1035+ textAlign : 'left' ,
1036+ writingDirection : 'rtl' ,
1037+ } ) ;
1038+ } ) ;
1039+
1040+ it ( 'places the accessories on the right side when RTL' , async ( ) => {
1041+ I18nManager . isRTL = true ;
1042+
1043+ await render (
1044+ < TextInput
1045+ label = "Email"
1046+ value = ""
1047+ onChangeText = { ( ) => { } }
1048+ startAccessory = { ( { style } ) => (
1049+ < View testID = "rtl-leading" style = { style } />
1050+ ) }
1051+ endAccessory = { ( { style } ) => < View testID = "rtl-trailing" style = { style } /> }
1052+ />
1053+ ) ;
1054+
1055+ const leadingStyle = StyleSheet . flatten (
1056+ // eslint-disable-next-line no-restricted-syntax -- reading resolved style.
1057+ screen . getByTestId ( 'rtl-leading' ) . props . style
1058+ ) ;
1059+ const trailingStyle = StyleSheet . flatten (
1060+ // eslint-disable-next-line no-restricted-syntax -- reading resolved style.
1061+ screen . getByTestId ( 'rtl-trailing' ) . props . style
1062+ ) ;
1063+ expect ( leadingStyle ) . toHaveProperty ( 'marginStart' ) ;
1064+ expect ( trailingStyle ) . toHaveProperty ( 'marginEnd' ) ;
1065+ } ) ;
1066+
1067+ it ( 'keeps StartAccessory before EndAccessory in the tree when RTL (the row mirrors)' , async ( ) => {
9911068 I18nManager . isRTL = true ;
9921069
9931070 function StartAccessory ( ) {
@@ -1010,9 +1087,9 @@ it('places EndAccessory before StartAccessory in the tree when RTL', async () =>
10101087 ) ;
10111088
10121089 const tree = toJSON ( ) ;
1013- expect ( firstIndexOfTestIdInTree ( tree , 'rtl-acc-from-end-prop' ) ) . toBeLessThan (
1090+ expect (
10141091 firstIndexOfTestIdInTree ( tree , 'rtl-acc-from-start-prop' )
1015- ) ;
1092+ ) . toBeLessThan ( firstIndexOfTestIdInTree ( tree , 'rtl-acc-from-end-prop' ) ) ;
10161093} ) ;
10171094
10181095it ( 'places StartAccessory before EndAccessory in the tree when LTR' , async ( ) => {
@@ -1164,7 +1241,7 @@ it('does not expose the placeholder string again after the TextInput loses focus
11641241 expect ( screen . getByTestId ( 'tf-input' ) . props . placeholder ) . toBe ( ' ' ) ;
11651242} ) ;
11661243
1167- it ( 'maps a lone StartAccessory to leading in LTR and trailing in RTL (tree order)' , async ( ) => {
1244+ it ( 'keeps a lone StartAccessory in the leading slot in LTR and RTL (tree order)' , async ( ) => {
11681245 function LoneStartAccessory ( ) {
11691246 return < View testID = "lone-start-acc" /> ;
11701247 }
@@ -1199,8 +1276,8 @@ it('maps a lone StartAccessory to leading in LTR and trailing in RTL (tree order
11991276 ) ;
12001277
12011278 const rtlTree = toJsonRtl ( ) ;
1202- expect ( firstIndexOfTestIdInTree ( rtlTree , 'tf- lone-rtl ' ) ) . toBeLessThan (
1203- firstIndexOfTestIdInTree ( rtlTree , 'lone-start-acc ' )
1279+ expect ( firstIndexOfTestIdInTree ( rtlTree , 'lone-start-acc ' ) ) . toBeLessThan (
1280+ firstIndexOfTestIdInTree ( rtlTree , 'tf- lone-rtl ' )
12041281 ) ;
12051282} ) ;
12061283
0 commit comments