File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 760
760
if ( this . error ) {
761
761
return 1 ;
762
762
}
763
+ if ( this . chunks . length === 1 ) {
764
+ this . _prevProgress = Math . max ( this . _prevProgress , this . chunks [ 0 ] . progress ( ) ) ;
765
+ return this . _prevProgress ;
766
+ }
763
767
// Sum up progress across everything
764
768
var bytesLoaded = 0 ;
765
769
each ( this . chunks , function ( c ) {
Original file line number Diff line number Diff line change @@ -289,4 +289,24 @@ describe('upload file', function() {
289
289
expect ( success ) . toHaveBeenCalled ( ) ;
290
290
expect ( retry ) . toHaveBeenCalled ( ) ;
291
291
} ) ;
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
+ } ) ;
292
312
} ) ;
You can’t perform that action at this time.
0 commit comments