@@ -152,6 +152,12 @@ describe('uploader', () => {
152152 expect ( container . querySelector ( 'input' ) ! . id ) . toBe ( 'bamboo' ) ;
153153 } ) ;
154154
155+ // https://github.com/ant-design/ant-design/issues/50643
156+ it ( 'with name' , ( ) => {
157+ const { container } = render ( < Upload name = "bamboo" /> ) ;
158+ expect ( container . querySelector ( 'input' ) ! . name ) . toBe ( 'bamboo' ) ;
159+ } ) ;
160+
155161 it ( 'should pass through data & aria attributes' , ( ) => {
156162 const { container } = render (
157163 < Upload
@@ -369,6 +375,31 @@ describe('uploader', () => {
369375 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
370376 await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
371377 } ) ;
378+
379+ it ( 'should pass file to request' , done => {
380+ const fakeRequest = jest . fn ( ( file ) => {
381+ expect ( file ) . toEqual ( expect . objectContaining ( {
382+ filename : 'file' , // <= https://github.com/react-component/upload/pull/574
383+ file : expect . any ( File ) ,
384+ method : 'post' ,
385+ onError : expect . any ( Function ) ,
386+ onProgress : expect . any ( Function ) ,
387+ onSuccess : expect . any ( Function ) ,
388+ data : expect . anything ( ) ,
389+ } ) ) ;
390+
391+ done ( ) ;
392+ } ) ;
393+
394+ const { container } = render ( < Upload customRequest = { fakeRequest } /> ) ;
395+ const input = container . querySelector ( 'input' ) ! ;
396+ const files = [ new File ( [ '' ] , 'success.png' , { type : 'image/png' } ) ] ;
397+ Object . defineProperty ( files , 'item' , {
398+ value : i => files [ i ] ,
399+ } ) ;
400+
401+ fireEvent . change ( input , { target : { files } } ) ;
402+ } ) ;
372403 } ) ;
373404
374405 describe ( 'directory uploader' , ( ) => {
0 commit comments