refactored tests

added done typings
This commit is contained in:
Neil Culver
2016-05-27 16:02:54 +01:00
parent 7537444460
commit dc4779445c
2 changed files with 25 additions and 21 deletions

View File

@@ -13,6 +13,18 @@ var __handleAddingFile = function (event:any, data:any)
data.submit();
};
var options: JQueryFileInputOptions = {
dataType: 'json',
singleFileUploads: true,
limitMultiFileUploads: 1,
add: __handleAddingFile,
done: (e, data) => {
data.result;
data.jqXHR;
data.textStatus;
}
}
class TestFileInput {
// The whole body will be the container for this test
@@ -24,20 +36,6 @@ class TestFileInput {
constructor() {
// The file upload object receives a fileInputOptions configuration object
this.fileInput = <JQueryFileUpload>this.$el.fileupload({
dataType: 'json',
// By default, each file of a selection is uploaded using an individual
// request for XHR type uploads. Set to false to upload file
// selections in one request each:
singleFileUploads: true,
// To limit the number of files uploaded with one XHR request,
// set the following option to an integer greater than 0:
limitMultiFileUploads: 1,
add: __handleAddingFile
});
this.fileInput = <JQueryFileUpload>this.$el.fileupload(options);
}
}

View File

@@ -212,7 +212,7 @@ interface JQueryFileInputOptions {
// Other callbacks:
submit?: Function;
done?: Function;
done?: (e: JQueryEventObject, data: JQueryFileUploadDone) => void;
fail?: Function;
always?: Function;
progressall?: (e: JQueryEventObject, data: JQueryFileUploadProgressAllObject) => void;
@@ -265,19 +265,25 @@ interface JQueryFileUploadProgressAllObject {
bitrate?: number;
}
interface JQueryFileUploadProgressObject extends JQueryFileInputOptions, JQueryFileUploadProgressAllObject {
interface JQueryFileUploadWithXhr {
jqXHR: JQueryXHR;
result: any;
textStatus: string;
}
interface JQueryFileUploadFilesObject {
files: File[];
}
interface JQueryFileUploadChunkObject extends JQueryFileInputOptions {
interface JQueryFileUploadChunkObject extends JQueryFileInputOptions, JQueryFileUploadWithXhr {
blob: any;
chunkSize: number;
contentRange: string;
errorThrown: any;
jqXHR: JQueryXHR;
result: any;
textStatus: string;
}
interface JQueryFileUploadProgressObject extends JQueryFileInputOptions, JQueryFileUploadProgressAllObject {
}
interface JQueryFileUploadDone extends JQueryFileInputOptions, JQueryFileUploadWithXhr {
}