DefinitelyTyped/fine-uploader/test/method.ts
Bradford Wagner f2d8c8ac18 Feature/fine uploader (#13768)
* Adding FineUploader typings

* noImplicitThis true

* adding tslint.json

* tslint.json -> tslint

* fixing some lintings

* fixing lintings

* removing version

* added typescript version

* defaults that are null/undefined now are | null/undefined respectively

* removed minor version from fineuploader definition, removed typescript 2 version
2017-01-05 12:37:43 -08:00

143 lines
4.1 KiB
TypeScript

/// <reference path="../index.d.ts" />
class TestMethods {
constructor(private uploader: qq.FineUploaderBasic) {
}
testAddFiles() {
type ParamType = {
field: string;
};
const params: ParamType = {
field: 'hiiiii'
};
this.uploader.addFiles(
new FileList(),
params,
"/my/happy/endpoint"
);
}
testAddInitialFiles() {
type InitialFiles = {
myField: number;
};
const initialFiles: InitialFiles[] = [{
myField: 1324
}];
this.uploader.addInitialFiles(initialFiles);
}
testDrawThumbnail() {
const promise: Promise<any> = this.uploader.drawThumbnail(
1234,
new HTMLElement(),
1234565,
false,
(resizeInfo) => {
return new Promise<File | Blob>(() => {
return new Blob();
});
}
)
}
testGetUploads() {
type ResponseType = {
hi: string;
}
let response: ResponseType | ResponseType[] = this.uploader.getUploads<ResponseType>({
status: "proggresssssssesees"
});
}
testSetCustomHeaders() {
type CustomHeader = {
customField: number
};
this.uploader.setCustomHeaders<CustomHeader>({
customField: 1234
}, 1234);
}
testSetDeleteCustomHeaders() {
type CustomHeader = {
customField: number
};
this.uploader.setDeleteFileCustomHeaders<CustomHeader>({
customField: 1234
}, 1234);
}
testSetDeleteFileParams() {
type CustomParams = {
paramField: boolean;
}
this.uploader.setDeleteFileParams<CustomParams>({
paramField: false
}, 1234);
}
testSetParams() {
type CustomParams = {
customParams: number;
};
this.uploader.setParams<CustomParams>({
customParams: 1234
}, 1234);
}
bulkTests() {
this.uploader.cancel(1);
this.uploader.cancelAll();
this.uploader.clearStoredFiles();
const shouldContinue: boolean = this.uploader.continueUpload(1234);
this.uploader.deleteFile(1234);
let elem: HTMLElement = this.uploader.getButton(1234);
let fileOrBlob: File | Blob = this.uploader.getFile(1234);
let num: number = this.uploader.getInProgress();
let s: string = this.uploader.getName(1234);
num = this.uploader.getParentId(1234);
num = this.uploader.getRemainingAllowedItems();
const resumables: qq.ResumableItem[] = this.uploader.getResumableFilesData();
num = this.uploader.getSize(1234);
s = this.uploader.getUuid(1234);
this.uploader.log("why am i doing this?", "info");
let b: boolean = this.uploader.pauseUpload(1234);
this.uploader.reset();
this.uploader.retry(1234);
const blobPromise: Promise<Blob> = this.uploader.scaleImage(1234, {
maxSize: 20,
orient: false,
type: "png",
quality: 10,
includeExif: false,
});
this.uploader.setEndpoint("/my/path/is/my/own", 1234);
this.uploader.setEndpoint("/my/path/is/my/own", new HTMLElement());
this.uploader.setDeleteFileEndpoint("/some/path", 1234);
this.uploader.setDeleteFileEndpoint("/some/path", new HTMLElement());
this.uploader.setItemLimit(1234);
this.uploader.setForm(new HTMLFormElement());
this.uploader.setForm("myFormElement");
this.uploader.setName(1234, "myCustomName");
this.uploader.setUuid(1234, "12341234");
this.uploader.uploadStoredFiles();
}
uiTests() {
this.uploader.addExtraDropzone(new HTMLElement());
let elem: HTMLElement = this.uploader.getDropTarget(1234);
let n: number = this.uploader.getId(elem);
elem = this.uploader.getItemByFileId(n);
this.uploader.removeExtraDropzone(elem);
}
}