File tree 3 files changed +26
-0
lines changed
RegistrationFields/NameField
3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,25 @@ describe('NameField', () => {
94
94
) ;
95
95
} ) ;
96
96
97
+ it ( 'should check for long full name error' , ( ) => {
98
+ const longName = `
99
+ 5cnx16mn7qTSbtiha1W473ZtV5prGBCEtNrfLkqizJirf
100
+ v5kbzBpLRbdh7FY5qujb8viQ9zPziE1fWnbFu5tj4FXaY5GDESvVwjQkE
101
+ txUPE3r9mk4HYcSfXVJPWAWRuK2LJZycZWDm0BMFLZ63YdyQAZhjyvjn7
102
+ SCqKjSHDx7mgwFp35PF4CxwtwNLxY11eqf5F88wQ9k2JQ9U8uKSFyTKCM
103
+ A456CGA5KjUugYdT1qKdvvnXtaQr8WA87m9jpe16
104
+ ` ;
105
+ const { container } = render ( routerWrapper ( reduxWrapper ( < IntlNameField { ...props } /> ) ) ) ;
106
+ const nameInput = container . querySelector ( 'input#name' ) ;
107
+ fireEvent . blur ( nameInput , { target : { value : longName , name : 'name' } } ) ;
108
+
109
+ expect ( props . handleErrorChange ) . toHaveBeenCalledTimes ( 1 ) ;
110
+ expect ( props . handleErrorChange ) . toHaveBeenCalledWith (
111
+ 'name' ,
112
+ 'Full name can not be longer than 255 symbols' ,
113
+ ) ;
114
+ } ) ;
115
+
97
116
it ( 'should clear error on focus' , ( ) => {
98
117
const { container } = render ( routerWrapper ( reduxWrapper ( < IntlNameField { ...props } /> ) ) ) ;
99
118
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ const validateName = (value, formatMessage) => {
15
15
fieldError = formatMessage ( messages [ 'empty.name.field.error' ] ) ;
16
16
} else if ( URL_REGEX . test ( value ) || HTML_REGEX . test ( value ) || INVALID_NAME_REGEX . test ( value ) ) {
17
17
fieldError = formatMessage ( messages [ 'name.validation.message' ] ) ;
18
+ } else if ( value && value . length > 255 ) {
19
+ fieldError = formatMessage ( messages [ 'name.validation.length.message' ] ) ;
18
20
}
19
21
return fieldError ;
20
22
} ;
Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ const messages = defineMessages({
126
126
defaultMessage : 'Enter a valid name' ,
127
127
description : 'Validation message that appears when fullname contain URL' ,
128
128
} ,
129
+ 'name.validation.length.message' : {
130
+ id : 'name.validation.message' ,
131
+ defaultMessage : 'Full name can not be longer than 255 symbols' ,
132
+ description : 'Validation message that appears when fullname contain URL' ,
133
+ } ,
129
134
'password.validation.message' : {
130
135
id : 'password.validation.message' ,
131
136
defaultMessage : 'Password criteria has not been met' ,
You can’t perform that action at this time.
0 commit comments