Convert done callbacks to async/await in test/unit/network_spec.js
This commit is contained in:
parent
fcf4d02fca
commit
5607484402
@ -20,7 +20,7 @@ describe("network", function () {
|
|||||||
const pdf1 = new URL("../pdfs/tracemonkey.pdf", window.location).href;
|
const pdf1 = new URL("../pdfs/tracemonkey.pdf", window.location).href;
|
||||||
const pdf1Length = 1016315;
|
const pdf1Length = 1016315;
|
||||||
|
|
||||||
it("read without stream and range", function (done) {
|
it("read without stream and range", async function () {
|
||||||
const stream = new PDFNetworkStream({
|
const stream = new PDFNetworkStream({
|
||||||
url: pdf1,
|
url: pdf1,
|
||||||
rangeChunkSize: 65536,
|
rangeChunkSize: 65536,
|
||||||
@ -49,22 +49,15 @@ describe("network", function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const readPromise = Promise.all([read(), promise]);
|
await Promise.all([read(), promise]);
|
||||||
|
|
||||||
readPromise
|
expect(len).toEqual(pdf1Length);
|
||||||
.then(function (page) {
|
expect(count).toEqual(1);
|
||||||
expect(len).toEqual(pdf1Length);
|
expect(isStreamingSupported).toEqual(false);
|
||||||
expect(count).toEqual(1);
|
expect(isRangeSupported).toEqual(false);
|
||||||
expect(isStreamingSupported).toEqual(false);
|
|
||||||
expect(isRangeSupported).toEqual(false);
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
.catch(function (reason) {
|
|
||||||
done.fail(reason);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("read custom ranges", function (done) {
|
it("read custom ranges", async function () {
|
||||||
// We don't test on browsers that don't support range request, so
|
// We don't test on browsers that don't support range request, so
|
||||||
// requiring this test to pass.
|
// requiring this test to pass.
|
||||||
const rangeSize = 32768;
|
const rangeSize = 32768;
|
||||||
@ -111,23 +104,16 @@ describe("network", function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const readPromises = Promise.all([
|
await Promise.all([
|
||||||
read(range1Reader, result1),
|
read(range1Reader, result1),
|
||||||
read(range2Reader, result2),
|
read(range2Reader, result2),
|
||||||
promise,
|
promise,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
readPromises
|
expect(result1.value).toEqual(rangeSize);
|
||||||
.then(function () {
|
expect(result2.value).toEqual(tailSize);
|
||||||
expect(result1.value).toEqual(rangeSize);
|
expect(isStreamingSupported).toEqual(false);
|
||||||
expect(result2.value).toEqual(tailSize);
|
expect(isRangeSupported).toEqual(true);
|
||||||
expect(isStreamingSupported).toEqual(false);
|
expect(fullReaderCancelled).toEqual(true);
|
||||||
expect(isRangeSupported).toEqual(true);
|
|
||||||
expect(fullReaderCancelled).toEqual(true);
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
.catch(function (reason) {
|
|
||||||
done.fail(reason);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user