Skip to content

Commit bf4fb48

Browse files
committed
* progress event
1 parent 1b3a096 commit bf4fb48

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/tests.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,30 @@ module('FileAPI');
307307

308308

309309
test('upload file', function (){
310+
var _progressFail = false;
310311
stop();
312+
311313
FileAPI.upload({
312314
url: 'http://rubaxa.org/FileAPI/server/ctrl.php',
313315
files: { text: FileAPI.getFiles(uploadForm['hello.txt']) },
316+
progress: function (evt){
317+
if( !_progressFail ){
318+
if( isNaN(evt.loaded / evt.total) ){
319+
_progressFail = true;
320+
ok(false, "progress: evt.loaded/evt.total - is NaN");
321+
}
322+
323+
if( isNaN(evt.loaded) ){
324+
_progressFail = true;
325+
ok(false, "progress: evt.loaded - is NaN");
326+
}
327+
328+
if( isNaN(evt.total) ){
329+
_progressFail = true;
330+
ok(false, "progress: evt.total - is NaN");
331+
}
332+
}
333+
},
314334
complete: function (err, res){
315335
start();
316336
var res = FileAPI.parseJSON(res.responseText).data._FILES['text'];
@@ -348,6 +368,24 @@ module('FileAPI');
348368
if( _progress > evt.loaded ){
349369
_progressFail = true;
350370
}
371+
372+
if( !_progressFail ){
373+
if( isNaN(evt.loaded/evt.total) ){
374+
_progressFail = true;
375+
ok(false, "progress: evt.loaded/evt.total - is NaN");
376+
}
377+
378+
if( isNaN(evt.loaded) ){
379+
_progressFail = true;
380+
ok(false, "progress: evt.loaded - is NaN");
381+
}
382+
383+
if( isNaN(evt.total) ){
384+
_progressFail = true;
385+
ok(false, "progress: evt.total - is NaN");
386+
}
387+
}
388+
351389
_progress = evt.loaded;
352390
},
353391
complete: function (err, xhr){

0 commit comments

Comments
 (0)