Skip to content

Commit

Permalink
made server errors show by default in onComplete, fixed tests to work…
Browse files Browse the repository at this point in the history
…s properly in IE
  • Loading branch information
Andrew Valums committed Sep 7, 2010
1 parent bfceade commit 6e24071
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions client/fileuploader.js
Expand Up @@ -335,6 +335,9 @@ qq.FileUploaderBasic.prototype = {
},
_onComplete: function(id, fileName, result){
this._filesInProgress--;
if (result.error){
this._options.showMessage(result.error);
}
},
_onCancel: function(id, fileName){
this._filesInProgress--;
Expand Down
4 changes: 4 additions & 0 deletions tests/action-acceptance.php
Expand Up @@ -26,6 +26,10 @@
die ('{error: "server-error file size is zero"}');
}

if ($fileSize < 10){
die ('{error: "server-error file size is smaller than 10 bytes"}');
}

if ($fileSize > 9 * 1024){
die ('{error: "server-error file size is bigger than 9kB"}');
}
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions tests/test-acceptance.htm
Expand Up @@ -44,7 +44,7 @@
setTimeout(function(){
same(uploader.getInProgress(), 1, 'getFilesInProgress');
}, 1);
} else if (fileName == '7text.txt'){
} else if (fileName == '8text.txt'){

setTimeout(function(){
same(uploader.getInProgress(), 0, 'all uploads should have finished');
Expand All @@ -66,7 +66,7 @@
} else if (fileName == '6text.txt'){
ok(responseJSON['new'] === 'newvalue' && responseJSON.one == null, "server received new params");
same(uploader.getInProgress(), 0, 'upload should have finished');
} else if (fileName == '7text.txt'){
} else if (fileName == '8text.txt'){
ok(false, "upload should be cancelled by returning false in onSubmit");
}
}
Expand All @@ -86,11 +86,11 @@ <h2 id="qunit-userAgent"></h2>
<li>select 1imagelong...long.gif, invalid ext error should appear</li>
<li>select 2larger.txt, invalid size message should appear (in FF3.6+,Safari4+,Chrome without doing request)</li>
<li>select 3empty.txt, invalid size message should appear (in FF3.6+,Safari4+,Chrome without doing request)</li>
<li>select 4text.txt, uploaded file should be marked as failed</li>
<li>select 4text.txt, uploaded file should be marked as failed (server returns jsgkdfgu4eyij)</li>
<li>select 5text.txt, callback argument tests</li>
<li>select 6text.txt, setParams, isUploading</li>
<li>select 7text.txt, returning false in onSubmit cancells upload, file should not be added to list</li>
<li>select 8small.txt, too small size message should appear</li>
<li>select 7small.txt, too small size message should appear (in FF3.6+,Safari4+,Chrome without doing request)</li>
<li>select 8text.txt, returning false in onSubmit cancells upload, file should not be added to list</li>
<li>
In FF,Chrome, select all files using drag-and-drop, only 1 error should appear.
</li>
Expand Down
8 changes: 4 additions & 4 deletions tests/test-upload-handlers.htm
Expand Up @@ -110,16 +110,16 @@
];

for (var i = 0, l = tests.length; i<l; i++) {
console.log('------------------ obj2url-test'+(i+1)+': '+tests[i].title);
console.log('object: '+tests[i].obj);
console.log('prefix: '+tests[i].prefix);
//console.log('------------------ obj2url-test'+(i+1)+': '+tests[i].title);
//console.log('object: '+tests[i].obj);
//console.log('prefix: '+tests[i].prefix);
var result = '';
if (tests[i].prefix) {
result = qq.obj2url(tests[i].obj, tests[i].prefix);
} else {
result = qq.obj2url(tests[i].obj);
}
console.log('result: '+result);
//console.log('result: '+result);
same(decodeURIComponent(result), tests[i].expect, tests[i].title);
}
});
Expand Down

0 comments on commit 6e24071

Please sign in to comment.