Skip to content

Commit

Permalink
Make AnnotationLayer unit tests more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Mar 9, 2023
1 parent 036dc10 commit 358c74f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Page/AnnotationLayer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit 358c74f

Please sign in to comment.