@@ -325,6 +325,54 @@ it('filters out files', async () => {
325325 await assertPendingValidateDebounceAndClear ( )
326326} )
327327
328+ it ( 'doesnt filter data when file validation is enabled' , async ( ) => {
329+ let config
330+ axios . request . mockImplementationOnce ( ( c ) => {
331+ config = c
332+ return Promise . resolve ( precognitionSuccessResponse ( ) )
333+ } )
334+
335+ const data = {
336+ name : 'Tim' ,
337+ email : null ,
338+ avatar : new Blob ( [ ] , { type : 'image/png' } ) ,
339+ }
340+
341+ const validator = createValidator ( ( client ) => client . post ( '/foo' , data ) )
342+
343+ validator . validateFiles ( )
344+ validator . validate ( 'text' , 'Tim' )
345+
346+ expect ( config . data ) . toEqual ( data ) ;
347+
348+ await assertPendingValidateDebounceAndClear ( )
349+ } )
350+
351+ it ( 'can disable file validation after enabling it' , async ( ) => {
352+ let config
353+ axios . request . mockImplementationOnce ( ( c ) => {
354+ config = c
355+ return Promise . resolve ( precognitionSuccessResponse ( ) )
356+ } )
357+
358+ const validator = createValidator ( ( client ) => client . post ( '/foo' , {
359+ name : 'Tim' ,
360+ email : null ,
361+ avatar : new Blob ( [ ] , { type : 'image/png' } ) ,
362+ } ) )
363+
364+ validator . validateFiles ( )
365+ validator . disableFileValidation ( )
366+ validator . validate ( 'text' , 'Tim' )
367+
368+ expect ( config . data ) . toEqual ( {
369+ name : 'Tim' ,
370+ email : null ,
371+ } ) ;
372+
373+ await assertPendingValidateDebounceAndClear ( )
374+ } )
375+
328376it ( 'doesnt mark fields as validated while response is pending' , async ( ) => {
329377 expect . assertions ( 10 )
330378
0 commit comments