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 pdf1Length = 1016315; | ||||
| 
 | ||||
|   it("read without stream and range", function (done) { | ||||
|   it("read without stream and range", async function () { | ||||
|     const stream = new PDFNetworkStream({ | ||||
|       url: pdf1, | ||||
|       rangeChunkSize: 65536, | ||||
| @ -49,22 +49,15 @@ describe("network", function () { | ||||
|       }); | ||||
|     }; | ||||
| 
 | ||||
|     const readPromise = Promise.all([read(), promise]); | ||||
|     await Promise.all([read(), promise]); | ||||
| 
 | ||||
|     readPromise | ||||
|       .then(function (page) { | ||||
|     expect(len).toEqual(pdf1Length); | ||||
|     expect(count).toEqual(1); | ||||
|     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
 | ||||
|     // requiring this test to pass.
 | ||||
|     const rangeSize = 32768; | ||||
| @ -111,23 +104,16 @@ describe("network", function () { | ||||
|       }); | ||||
|     }; | ||||
| 
 | ||||
|     const readPromises = Promise.all([ | ||||
|     await Promise.all([ | ||||
|       read(range1Reader, result1), | ||||
|       read(range2Reader, result2), | ||||
|       promise, | ||||
|     ]); | ||||
| 
 | ||||
|     readPromises | ||||
|       .then(function () { | ||||
|     expect(result1.value).toEqual(rangeSize); | ||||
|     expect(result2.value).toEqual(tailSize); | ||||
|     expect(isStreamingSupported).toEqual(false); | ||||
|     expect(isRangeSupported).toEqual(true); | ||||
|     expect(fullReaderCancelled).toEqual(true); | ||||
|         done(); | ||||
|       }) | ||||
|       .catch(function (reason) { | ||||
|         done.fail(reason); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user