File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 760760 if ( this . error ) {
761761 return 1 ;
762762 }
763+ if ( this . chunks . length === 1 ) {
764+ this . _prevProgress = Math . max ( this . _prevProgress , this . chunks [ 0 ] . progress ( ) ) ;
765+ return this . _prevProgress ;
766+ }
763767 // Sum up progress across everything
764768 var bytesLoaded = 0 ;
765769 each ( this . chunks , function ( c ) {
Original file line number Diff line number Diff line change @@ -289,4 +289,24 @@ describe('upload file', function() {
289289 expect ( success ) . toHaveBeenCalled ( ) ;
290290 expect ( retry ) . toHaveBeenCalled ( ) ;
291291 } ) ;
292+
293+ it ( 'should upload empty file' , function ( ) {
294+ var error = jasmine . createSpy ( 'error' ) ;
295+ var success = jasmine . createSpy ( 'success' ) ;
296+ resumable . on ( 'fileError' , error ) ;
297+ resumable . on ( 'fileSuccess' , success ) ;
298+
299+ resumable . addFile ( new Blob ( [ ] ) ) ;
300+ var file = resumable . files [ 0 ] ;
301+ resumable . upload ( ) ;
302+ expect ( requests . length ) . toBe ( 1 ) ;
303+ expect ( file . progress ( ) ) . toBe ( 0 ) ;
304+ requests [ 0 ] . respond ( 200 ) ;
305+ expect ( requests . length ) . toBe ( 1 ) ;
306+ expect ( error ) . not . toHaveBeenCalled ( ) ;
307+ expect ( success ) . toHaveBeenCalled ( ) ;
308+ expect ( file . progress ( ) ) . toBe ( 1 ) ;
309+ expect ( file . isUploading ( ) ) . toBe ( false ) ;
310+ expect ( file . isComplete ( ) ) . toBe ( true ) ;
311+ } ) ;
292312} ) ;
You can’t perform that action at this time.
0 commit comments