@@ -113,26 +113,6 @@ describe('Unit Test cases for use-form hook', () => {
113113 ) ;
114114 expect ( result . current [ 0 ] . name . isValid ) . toBe ( true ) ;
115115 expect ( result . current [ 1 ] . isValid ) . toBe ( true ) ;
116- const incorrectSpaceTextAtStart = ' text' ;
117- await act ( async ( ) => {
118- await result . current [ 0 ] . name . setValue ( incorrectSpaceTextAtStart ) ;
119- } ) ;
120- expect ( result . current [ 0 ] . name . value ) . toBe ( incorrectSpaceTextAtStart ) ;
121- expect ( result . current [ 0 ] . name . isValid ) . toBe ( false ) ;
122- expect ( result . current [ 1 ] . isValid ) . toBe ( false ) ;
123- expect ( result . current [ 0 ] . name . errorMsg ) . toBe (
124- 'This is custom error message' ,
125- ) ;
126- const incorrectSpaceTextAtEnd = 'text ' ;
127- await act ( async ( ) => {
128- await result . current [ 0 ] . name . setValue ( incorrectSpaceTextAtEnd ) ;
129- } ) ;
130- expect ( result . current [ 0 ] . name . value ) . toBe ( incorrectSpaceTextAtEnd ) ;
131- expect ( result . current [ 0 ] . name . isValid ) . toBe ( false ) ;
132- expect ( result . current [ 1 ] . isValid ) . toBe ( false ) ;
133- expect ( result . current [ 0 ] . name . errorMsg ) . toBe (
134- 'This is custom error message' ,
135- ) ;
136116 const incorrectText = 'text' ;
137117 await act ( async ( ) => {
138118 await result . current [ 0 ] . name . setValue ( incorrectText ) ;
@@ -195,20 +175,6 @@ describe('Unit Test cases for use-form hook', () => {
195175 const { result } = renderHook ( ( ) => useForm ( { name : { max : 5 } } ) ) ;
196176 expect ( result . current [ 0 ] . name . isValid ) . toBe ( true ) ;
197177 expect ( result . current [ 1 ] . isValid ) . toBe ( true ) ;
198- const incorrectSpaceTextAtStart = ' text' ;
199- await act ( async ( ) => {
200- await result . current [ 0 ] . name . setValue ( incorrectSpaceTextAtStart ) ;
201- } ) ;
202- expect ( result . current [ 0 ] . name . value ) . toBe ( incorrectSpaceTextAtStart ) ;
203- expect ( result . current [ 0 ] . name . isValid ) . toBe ( true ) ;
204- expect ( result . current [ 1 ] . isValid ) . toBe ( true ) ;
205- const incorrectSpaceTextAtEnd = 'textWithSpace ' ;
206- await act ( async ( ) => {
207- await result . current [ 0 ] . name . setValue ( incorrectSpaceTextAtEnd ) ;
208- } ) ;
209- expect ( result . current [ 0 ] . name . value ) . toBe ( incorrectSpaceTextAtEnd ) ;
210- expect ( result . current [ 0 ] . name . isValid ) . toBe ( false ) ;
211- expect ( result . current [ 1 ] . isValid ) . toBe ( false ) ;
212178 const incorrectText = 'superlongtext' ;
213179 await act ( async ( ) => {
214180 await result . current [ 0 ] . name . setValue ( incorrectText ) ;
@@ -267,23 +233,6 @@ describe('Unit Test cases for use-form hook', () => {
267233 ) ;
268234 expect ( result . current [ 0 ] . name . isValid ) . toBe ( true ) ;
269235 expect ( result . current [ 1 ] . isValid ) . toBe ( true ) ;
270- const incorrectSpaceTextAtStart = ' text' ;
271- await act ( async ( ) => {
272- await result . current [ 0 ] . name . setValue ( incorrectSpaceTextAtStart ) ;
273- } ) ;
274- expect ( result . current [ 0 ] . name . value ) . toBe ( incorrectSpaceTextAtStart ) ;
275- expect ( result . current [ 0 ] . name . isValid ) . toBe ( true ) ;
276- expect ( result . current [ 1 ] . isValid ) . toBe ( true ) ;
277- const incorrectSpaceTextAtEnd = 'textWithSpace ' ;
278- await act ( async ( ) => {
279- await result . current [ 0 ] . name . setValue ( incorrectSpaceTextAtEnd ) ;
280- } ) ;
281- expect ( result . current [ 0 ] . name . value ) . toBe ( incorrectSpaceTextAtEnd ) ;
282- expect ( result . current [ 0 ] . name . isValid ) . toBe ( false ) ;
283- expect ( result . current [ 1 ] . isValid ) . toBe ( false ) ;
284- expect ( result . current [ 0 ] . name . errorMsg ) . toBe (
285- 'This is custom error message' ,
286- ) ;
287236 const incorrectText = 'superlongtext' ;
288237 await act ( async ( ) => {
289238 await result . current [ 0 ] . name . setValue ( incorrectText ) ;
0 commit comments