File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React from "react" ;
22import "jest-styled-components" ;
33import renderWithTheme from "../../../../tests/hoc/shallowWithTheme" ;
4- import { EmailSignUp , validationSchema } from "./_EmailSignUp" ;
4+ import { EmailSignUp , buildEsuValidationSchema } from "./_EmailSignUp" ;
55import RichText from "../../Atoms/RichText/RichText" ;
66import { useForm , FormProvider } from "react-hook-form" ;
77import { yupResolver } from "@hookform/resolvers/yup" ;
88
99const DummyForm = ( ) => {
1010 const formMethods = useForm ( {
1111 mode : "onBlur" ,
12- resolver : yupResolver ( validationSchema ) ,
12+ resolver : yupResolver ( buildEsuValidationSchema ( ) ) ,
1313 } ) ;
1414 const { handleSubmit } = formMethods ;
1515
Original file line number Diff line number Diff line change @@ -34,15 +34,15 @@ const buildEsuValidationSchema = overrides => {
3434 . string ( )
3535 . required ( 'Please enter your first name' )
3636 . matches (
37- / ^ [ A - Z a - z ] [ A - Z a - z ' - ] * $ / ,
37+ / ^ \p { L } [ \p { L } ' - ] * $ / u ,
3838 "This field only accepts letters and ' - and must start with a letter"
3939 )
4040 . max ( 25 , 'Your first name must be between 1 and 25 characters' ) ,
4141 [ ESU_FIELDS . LAST_NAME ] : yup
4242 . string ( )
4343 . required ( 'Please enter your last name' )
4444 . matches (
45- / ^ [ A - Z a - z ] [ A - Z a - z ' - ] * $ / ,
45+ / ^ \p { L } [ \p { L } ' - ] * $ / u ,
4646 "This field only accepts letters and ' - and must start with a letter"
4747 )
4848 . max ( 50 , 'Your last name must be between 1 and 50 characters' ) ,
Original file line number Diff line number Diff line change 1+ import { buildEsuValidationSchema , ESU_FIELDS } from './emailSignupConfig' ;
2+
3+ describe ( 'buildEsuValidationSchema' , ( ) => {
4+ const schema = buildEsuValidationSchema ( { } ) ;
5+
6+ it ( 'accepts first and last names with accented Latin letters' , async ( ) => {
7+ await expect (
8+ schema . validate ( {
9+ [ ESU_FIELDS . FIRST_NAME ] : 'André' ,
10+ [ ESU_FIELDS . LAST_NAME ] : 'François' ,
11+ [ ESU_FIELDS . EMAIL ] : 'andre.francois@example.com'
12+ } )
13+ ) . resolves . toEqual ( {
14+ [ ESU_FIELDS . FIRST_NAME ] : 'André' ,
15+ [ ESU_FIELDS . LAST_NAME ] : 'François' ,
16+ [ ESU_FIELDS . EMAIL ] : 'andre.francois@example.com'
17+ } ) ;
18+ } ) ;
19+ } ) ;
You can’t perform that action at this time.
0 commit comments