@@ -152,12 +152,6 @@ 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-
161155 it ( 'should pass through data & aria attributes' , ( ) => {
162156 const { container } = render (
163157 < Upload
@@ -375,6 +369,31 @@ describe('uploader', () => {
375369 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
376370 await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
377371 } ) ;
372+
373+ it ( 'should pass file to request' , done => {
374+ const fakeRequest = jest . fn ( ( file ) => {
375+ expect ( file ) . toEqual ( expect . objectContaining ( {
376+ filename : 'file' , // <= https://github.com/react-component/upload/pull/574
377+ file : expect . any ( File ) ,
378+ method : 'post' ,
379+ onError : expect . any ( Function ) ,
380+ onProgress : expect . any ( Function ) ,
381+ onSuccess : expect . any ( Function ) ,
382+ data : expect . anything ( ) ,
383+ } ) ) ;
384+
385+ done ( ) ;
386+ } ) ;
387+
388+ const { container } = render ( < Upload customRequest = { fakeRequest } /> ) ;
389+ const input = container . querySelector ( 'input' ) ! ;
390+ const files = [ new File ( [ '' ] , 'success.png' , { type : 'image/png' } ) ] ;
391+ Object . defineProperty ( files , 'item' , {
392+ value : i => files [ i ] ,
393+ } ) ;
394+
395+ fireEvent . change ( input , { target : { files } } ) ;
396+ } ) ;
378397 } ) ;
379398
380399 describe ( 'directory uploader' , ( ) => {
0 commit comments