Skip to content

Commit

Permalink
FileUploader: Test chunk_size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Davit Barbakadze committed Mar 7, 2017
1 parent 29e453e commit f5cd267
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions tests/auto/FileUploader.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,22 @@
"Item is an instance of plupload.ChunkUploader.");

deepEqual(item.getOptions(), {
chunk_size: 0,
file_data_name: 'file',
headers: false,
http_method: 'POST',
multipart: true,
params: {},
send_file_name: false,
stop_on_fail: true,
url: 'upload.php'
},
"Options have expected values.");

});

up.bind('resumed', function() {
this.start();
});

up.bind('processed', function() {
QUnit.start();
});
Expand All @@ -102,6 +104,62 @@
});


test("Options: chunk_size='200kb'", function() {
var self = this;

var dispatched = {
'started': 0,
'beforestart': 0,
//'chunkuploadfailed': 0,
'chunkuploaded': 0,
'progress': 0,
//'paused': 0
};

var up = new plupload.FileUploader(this.file, this.queue);

var chunkSize = plupload.parseSize('10kb');
var chunksNum = Math.ceil(this.file.size / chunkSize);

// monitor events
plupload.each(dispatched, function(num, type) {
up.bind(type, function() {
dispatched[type]++;
});
});

up.bind('resumed', function() {
this.start();
});

up.bind('started', function() {

ok(true, "started event has been dispatched.");

equal(self.queue.stats.queued, chunksNum,
chunksNum + " item(s) added to the queue.");

var item = getItemAt(0, self.queue);
ok(item instanceof plupload.ChunkUploader,
"Item is an instance of plupload.ChunkUploader.");


});

up.bind('processed', function() {
QUnit.start();
plupload.each(dispatched, function(num, type) {
ok(num > 0, type + ' has been dispatched ' + num + ' times.');
});
});

up.setOption('chunk_size', chunkSize);

QUnit.stop();
up.start();
});


// test options immutability in uploadCHunk()

// _options.chunk_size set and not
Expand Down

0 comments on commit f5cd267

Please sign in to comment.