@@ -241,4 +241,37 @@ describe('upload file', function() {
241241 expect ( file . isUploading ( ) ) . toBeFalsy ( ) ;
242242 expect ( file . progress ( ) ) . toBe ( 1 ) ;
243243 } ) ;
244+
245+ it ( 'should retry file with timeout' , function ( ) {
246+ jasmine . Clock . useMock ( ) ;
247+ resumable . opts . testChunks = false ;
248+ resumable . opts . maxChunkRetries = 1 ;
249+ resumable . opts . chunkRetryInterval = 100 ;
250+
251+ var error = jasmine . createSpy ( 'error' ) ;
252+ var success = jasmine . createSpy ( 'success' ) ;
253+ var retry = jasmine . createSpy ( 'retry' ) ;
254+ resumable . on ( 'fileError' , error ) ;
255+ resumable . on ( 'fileSuccess' , success ) ;
256+ resumable . on ( 'fileRetry' , retry ) ;
257+
258+ resumable . addFile ( new Blob ( [ '12' ] ) ) ;
259+ var file = resumable . files [ 0 ] ;
260+ resumable . upload ( ) ;
261+ expect ( requests . length ) . toBe ( 1 ) ;
262+
263+ requests [ 0 ] . respond ( 400 ) ;
264+ expect ( requests . length ) . toBe ( 1 ) ;
265+ expect ( error ) . not . toHaveBeenCalled ( ) ;
266+ expect ( success ) . not . toHaveBeenCalled ( ) ;
267+ expect ( retry ) . toHaveBeenCalled ( ) ;
268+ expect ( file . chunks [ 0 ] . status ( ) ) . toBe ( 'uploading' ) ;
269+
270+ jasmine . Clock . tick ( 100 ) ;
271+ expect ( requests . length ) . toBe ( 2 ) ;
272+ requests [ 1 ] . respond ( 200 ) ;
273+ expect ( error ) . not . toHaveBeenCalled ( ) ;
274+ expect ( success ) . toHaveBeenCalled ( ) ;
275+ expect ( retry ) . toHaveBeenCalled ( ) ;
276+ } ) ;
244277} ) ;
0 commit comments