Convert done callbacks to async/await in test/unit/fetch_stream_spec.js
This commit is contained in:
parent
5607484402
commit
a1c1e1b9f8
@ -20,7 +20,7 @@ describe("fetch_stream", function () {
|
||||
const pdfUrl = new URL("../pdfs/tracemonkey.pdf", window.location).href;
|
||||
const pdfLength = 1016315;
|
||||
|
||||
it("read with streaming", function (done) {
|
||||
it("read with streaming", async function () {
|
||||
const stream = new PDFFetchStream({
|
||||
url: pdfUrl,
|
||||
disableStream: false,
|
||||
@ -47,18 +47,14 @@ describe("fetch_stream", function () {
|
||||
});
|
||||
};
|
||||
|
||||
const readPromise = Promise.all([read(), promise]);
|
||||
readPromise
|
||||
.then(function () {
|
||||
await Promise.all([read(), promise]);
|
||||
|
||||
expect(len).toEqual(pdfLength);
|
||||
expect(isStreamingSupported).toEqual(true);
|
||||
expect(isRangeSupported).toEqual(false);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("read ranges with streaming", function (done) {
|
||||
it("read ranges with streaming", async function () {
|
||||
const rangeSize = 32768;
|
||||
const stream = new PDFFetchStream({
|
||||
url: pdfUrl,
|
||||
@ -98,20 +94,16 @@ describe("fetch_stream", function () {
|
||||
});
|
||||
};
|
||||
|
||||
const readPromise = Promise.all([
|
||||
await Promise.all([
|
||||
read(rangeReader1, result1),
|
||||
read(rangeReader2, result2),
|
||||
promise,
|
||||
]);
|
||||
readPromise
|
||||
.then(function () {
|
||||
|
||||
expect(isStreamingSupported).toEqual(true);
|
||||
expect(isRangeSupported).toEqual(true);
|
||||
expect(fullReaderCancelled).toEqual(true);
|
||||
expect(result1.value).toEqual(rangeSize);
|
||||
expect(result2.value).toEqual(tailSize);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user