diff --git a/test/unit/fetch_stream_spec.js b/test/unit/fetch_stream_spec.js index d819b2c6d..2ff1b41ec 100644 --- a/test/unit/fetch_stream_spec.js +++ b/test/unit/fetch_stream_spec.js @@ -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 () { - expect(len).toEqual(pdfLength); - expect(isStreamingSupported).toEqual(true); - expect(isRangeSupported).toEqual(false); - done(); - }) - .catch(done.fail); + await Promise.all([read(), promise]); + + expect(len).toEqual(pdfLength); + expect(isStreamingSupported).toEqual(true); + expect(isRangeSupported).toEqual(false); }); - 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); + + expect(isStreamingSupported).toEqual(true); + expect(isRangeSupported).toEqual(true); + expect(fullReaderCancelled).toEqual(true); + expect(result1.value).toEqual(rangeSize); + expect(result2.value).toEqual(tailSize); }); });