@@ -290,6 +290,32 @@ describe('upload file', function() {
290290 expect ( retry ) . toHaveBeenCalled ( ) ;
291291 } ) ;
292292
293+ it ( 'should fail on permanent error' , function ( ) {
294+ resumable . opts . testChunks = false ;
295+ resumable . opts . chunkSize = 1 ;
296+ resumable . opts . simultaneousUploads = 2 ;
297+ resumable . opts . maxChunkRetries = 1 ;
298+ resumable . opts . permanentErrors = [ 500 ] ;
299+
300+ var error = jasmine . createSpy ( 'error' ) ;
301+ var success = jasmine . createSpy ( 'success' ) ;
302+ var retry = jasmine . createSpy ( 'retry' ) ;
303+ resumable . on ( 'fileError' , error ) ;
304+ resumable . on ( 'fileSuccess' , success ) ;
305+ resumable . on ( 'fileRetry' , retry ) ;
306+
307+ resumable . addFile ( new Blob ( [ 'abc' ] ) ) ;
308+ var file = resumable . files [ 0 ] ;
309+ expect ( file . chunks . length ) . toBe ( 3 ) ;
310+ resumable . upload ( ) ;
311+ expect ( requests . length ) . toBe ( 2 ) ;
312+ requests [ 0 ] . respond ( 500 ) ;
313+ expect ( requests . length ) . toBe ( 2 ) ;
314+ expect ( error ) . toHaveBeenCalled ( ) ;
315+ expect ( retry ) . not . toHaveBeenCalled ( ) ;
316+ expect ( success ) . not . toHaveBeenCalled ( ) ;
317+ } ) ;
318+
293319 it ( 'should upload empty file' , function ( ) {
294320 var error = jasmine . createSpy ( 'error' ) ;
295321 var success = jasmine . createSpy ( 'success' ) ;
0 commit comments