Convert done callbacks to async/await in test/unit/display_svg_spec.js
				
					
				
			This commit is contained in:
		
							parent
							
								
									cd2c4e277c
								
							
						
					
					
						commit
						bc8c0bbbfd
					
				@ -59,17 +59,15 @@ function withZlib(isZlibRequired, callback) {
 | 
				
			|||||||
describe("SVGGraphics", function () {
 | 
					describe("SVGGraphics", function () {
 | 
				
			||||||
  let loadingTask;
 | 
					  let loadingTask;
 | 
				
			||||||
  let page;
 | 
					  let page;
 | 
				
			||||||
  beforeAll(function (done) {
 | 
					
 | 
				
			||||||
 | 
					  beforeAll(async function () {
 | 
				
			||||||
    loadingTask = getDocument(buildGetDocumentParams("xobject-image.pdf"));
 | 
					    loadingTask = getDocument(buildGetDocumentParams("xobject-image.pdf"));
 | 
				
			||||||
    loadingTask.promise.then(function (doc) {
 | 
					    const doc = await loadingTask.promise;
 | 
				
			||||||
      doc.getPage(1).then(function (firstPage) {
 | 
					    page = await doc.getPage(1);
 | 
				
			||||||
        page = firstPage;
 | 
					 | 
				
			||||||
        done();
 | 
					 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
    });
 | 
					
 | 
				
			||||||
  });
 | 
					  afterAll(async function () {
 | 
				
			||||||
  afterAll(function (done) {
 | 
					    await loadingTask.destroy();
 | 
				
			||||||
    loadingTask.destroy().then(done);
 | 
					 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe("paintImageXObject", function () {
 | 
					  describe("paintImageXObject", function () {
 | 
				
			||||||
@ -129,12 +127,11 @@ describe("SVGGraphics", function () {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should produce a reasonably small svg:image", function (done) {
 | 
					    it("should produce a reasonably small svg:image", async function () {
 | 
				
			||||||
      if (!isNodeJS) {
 | 
					      if (!isNodeJS) {
 | 
				
			||||||
        pending("zlib.deflateSync is not supported in non-Node environments.");
 | 
					        pending("zlib.deflateSync is not supported in non-Node environments.");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      withZlib(true, getSVGImage)
 | 
					      const svgImg = await withZlib(true, getSVGImage);
 | 
				
			||||||
        .then(function (svgImg) {
 | 
					 | 
				
			||||||
      expect(svgImg.nodeName).toBe("svg:image");
 | 
					      expect(svgImg.nodeName).toBe("svg:image");
 | 
				
			||||||
      expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
 | 
					      expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
 | 
				
			||||||
      expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
 | 
					      expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
 | 
				
			||||||
@ -146,13 +143,10 @@ describe("SVGGraphics", function () {
 | 
				
			|||||||
      // Without zlib (uncompressed), the size of the data URL was excessive
 | 
					      // Without zlib (uncompressed), the size of the data URL was excessive
 | 
				
			||||||
      // (80246).
 | 
					      // (80246).
 | 
				
			||||||
      expect(imgUrl.length).toBeLessThan(367);
 | 
					      expect(imgUrl.length).toBeLessThan(367);
 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
        .then(done, done.fail);
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should be able to produce a svg:image without zlib", function (done) {
 | 
					    it("should be able to produce a svg:image without zlib", async function () {
 | 
				
			||||||
      withZlib(false, getSVGImage)
 | 
					      const svgImg = await withZlib(false, getSVGImage);
 | 
				
			||||||
        .then(function (svgImg) {
 | 
					 | 
				
			||||||
      expect(svgImg.nodeName).toBe("svg:image");
 | 
					      expect(svgImg.nodeName).toBe("svg:image");
 | 
				
			||||||
      expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
 | 
					      expect(svgImg.getAttributeNS(null, "width")).toBe("200px");
 | 
				
			||||||
      expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
 | 
					      expect(svgImg.getAttributeNS(null, "height")).toBe("100px");
 | 
				
			||||||
@ -160,8 +154,6 @@ describe("SVGGraphics", function () {
 | 
				
			|||||||
      expect(imgUrl).toMatch(/^data:image\/png;base64,/);
 | 
					      expect(imgUrl).toMatch(/^data:image\/png;base64,/);
 | 
				
			||||||
      // The size of our naively generated PNG file is excessive :(
 | 
					      // The size of our naively generated PNG file is excessive :(
 | 
				
			||||||
      expect(imgUrl.length).toBe(80246);
 | 
					      expect(imgUrl.length).toBe(80246);
 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
        .then(done, done.fail);
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user