Skip to content

Commit db2028d

Browse files
committed
test(preprocess): chunk sould be preprocessed
1 parent 366f8dd commit db2028d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/uploadSpec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,24 @@ describe('upload file', function() {
360360
});
361361
expect(resumable.files.length).toBe(0);
362362
});
363+
364+
it('should preprocess chunks', function () {
365+
var preprocess = jasmine.createSpy('preprocess');
366+
var error = jasmine.createSpy('error');
367+
var success = jasmine.createSpy('success');
368+
resumable.on('fileError', error);
369+
resumable.on('fileSuccess', success);
370+
resumable.opts.preprocess = preprocess;
371+
resumable.addFile(new Blob(['abc']));
372+
var file = resumable.files[0];
373+
resumable.upload();
374+
expect(requests.length).toBe(0);
375+
expect(preprocess).wasCalledWith(file.chunks[0]);
376+
expect(file.chunks[0].preprocessState).toBe(1);
377+
file.chunks[0].preprocessFinished();
378+
expect(requests.length).toBe(1);
379+
requests[0].respond(200, [], "response");
380+
expect(success).wasCalledWith(file, "response");
381+
expect(error).not.toHaveBeenCalled();
382+
});
363383
});

0 commit comments

Comments
 (0)