Fix build error and refine cancel test

This commit is contained in:
Rikki Gibson 2018-05-18 11:46:42 -07:00
Родитель 18d5680097
Коммит e0784865ec
2 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -298,7 +298,7 @@ export interface RequestPrepareOptions {
deserializationMapper?: object;
disableJsonStringifyOnBody?: boolean;
bodyIsStream?: boolean;
cancellationToken: CancellationTokenLike;
cancellationToken?: CancellationTokenLike;
}
/**

Просмотреть файл

@ -98,13 +98,16 @@ describe("axiosHttpClient", () => {
});
});
it("should allow canceling requests", async () => {
it("should allow canceling requests", async function() {
// ensure that a large upload is actually cancelled
this.timeout(200);
const cancellationToken: CancellationTokenLike = {
setCancellationListener: function(listener){ this.cancel = listener },
setCancellationListener: (listener) => { cancellationToken.cancel = listener },
cancel: () => {}
};
const request = new WebResource(`{baseURL}/httpbin-index.html`, "GET", undefined, undefined, undefined, false, cancellationToken);
const request = new WebResource(`${baseURL}/fileupload`, "POST", new Uint8Array(1024*1024*100), undefined, undefined, true, cancellationToken);
const client = new AxiosHttpClient();
const promise = client.sendRequest(request);
cancellationToken.cancel();