From b49c11624d2365f56eb6f63583cfb82cab48884b Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Thu, 9 Mar 2023 09:20:18 +0100 Subject: [PATCH] Make AnnotationLayer unit tests more resilient --- src/Page/AnnotationLayer.spec.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Page/AnnotationLayer.spec.jsx b/src/Page/AnnotationLayer.spec.jsx index ded157b76..056ac366e 100644 --- a/src/Page/AnnotationLayer.spec.jsx +++ b/src/Page/AnnotationLayer.spec.jsx @@ -236,11 +236,13 @@ describe('AnnotationLayer', () => { const annotationLayer = container.firstElementChild; + const { width, height } = window.getComputedStyle(annotationLayer); + const viewport = page.getViewport({ scale: 1 }); // Expect the annotation layer to be rotated - expect(parseInt(annotationLayer.style.width, 10)).toBe(Math.floor(viewport.width)); - expect(parseInt(annotationLayer.style.height, 10)).toBe(Math.floor(viewport.height)); + expect(parseInt(width, 10)).toBe(Math.floor(viewport.width)); + expect(parseInt(height, 10)).toBe(Math.floor(viewport.height)); }); it('renders annotations at a given scale', async () => { @@ -265,11 +267,13 @@ describe('AnnotationLayer', () => { const annotationLayer = container.firstElementChild; + const { width, height } = window.getComputedStyle(annotationLayer); + const viewport = page.getViewport({ scale }); // Expect the annotation layer to be scaled - expect(parseInt(annotationLayer.style.width, 10)).toBe(Math.floor(viewport.width)); - expect(parseInt(annotationLayer.style.height, 10)).toBe(Math.floor(viewport.height)); + expect(parseInt(width, 10)).toBe(Math.floor(viewport.width)); + expect(parseInt(height, 10)).toBe(Math.floor(viewport.height)); }); it('renders annotations with the default imageResourcesPath given no imageResourcesPath', async () => {