File tree Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -124,13 +124,13 @@ const HelperText = ({
124
124
125
125
const { colors, dark } = theme ;
126
126
127
- const textColor =
128
- type === 'error'
129
- ? colors ?. error
130
- : color ( theme . isV3 ? theme . colors . onSurface : theme ?. colors ?. text )
131
- . alpha ( dark ? 0.7 : 0.54 )
132
- . rgb ( )
133
- . string ( ) ;
127
+ const infoTextColor = theme . isV3
128
+ ? theme . colors . onSurfaceVariant
129
+ : color ( theme ?. colors ?. text )
130
+ . alpha ( dark ? 0.7 : 0.54 )
131
+ . rgb ( )
132
+ . string ( ) ;
133
+ const textColor = type === 'error' ? colors ?. error : infoTextColor ;
134
134
135
135
return (
136
136
< AnimatedText
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { render } from '@testing-library/react-native' ;
4
+
5
+ import { getTheme } from '../../core/theming' ;
6
+ import HelperText from '../HelperText' ;
7
+
8
+ describe ( 'HelperText' , ( ) => {
9
+ it ( 'should have correct text color for info type' , ( ) => {
10
+ const { getByTestId } = render (
11
+ < HelperText testID = "helper-text" type = "info" >
12
+ Info: Maximum length is 100 characters
13
+ </ HelperText >
14
+ ) ;
15
+
16
+ expect ( getByTestId ( 'helper-text' ) ) . toHaveStyle ( {
17
+ color : getTheme ( ) . colors . onSurfaceVariant ,
18
+ } ) ;
19
+ } ) ;
20
+
21
+ it ( 'should have correct text color for error type' , ( ) => {
22
+ const { getByTestId } = render (
23
+ < HelperText testID = "helper-text" type = "error" >
24
+ Error: Only letters are allowed
25
+ </ HelperText >
26
+ ) ;
27
+
28
+ expect ( getByTestId ( 'helper-text' ) ) . toHaveStyle ( {
29
+ color : getTheme ( ) . colors . error ,
30
+ } ) ;
31
+ } ) ;
32
+ } ) ;
You can’t perform that action at this time.
0 commit comments