Skip to content

Commit

Permalink
Minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Mar 7, 2023
1 parent 4f2ac42 commit d66b6b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Document.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Document', () => {
);

expect.assertions(2);

await expect(onSourceSuccessPromise).resolves.toBe(OK);
await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPdf);
});
Expand All @@ -78,6 +79,7 @@ describe('Document', () => {
);

expect.assertions(2);

await expect(onSourceSuccessPromise).resolves.toBe(OK);
await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPdf);
});
Expand All @@ -96,6 +98,7 @@ describe('Document', () => {
);

expect.assertions(2);

await expect(onSourceSuccessPromise).resolves.toBe(OK);
await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPdf);
});
Expand All @@ -113,6 +116,7 @@ describe('Document', () => {
);

expect.assertions(2);

await expect(onSourceSuccessPromise).resolves.toBe(OK);
await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPdf);
});
Expand All @@ -130,6 +134,7 @@ describe('Document', () => {
);

expect.assertions(2);

await expect(onSourceSuccessPromise).resolves.toBe(OK);
await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPdf);
});
Expand Down Expand Up @@ -350,6 +355,7 @@ describe('Document', () => {
await onLoadSuccessPromise;

const child = getByTestId(container, 'child');

expect(child.dataset.rendermode).toBe('svg');
});

Expand All @@ -367,6 +373,7 @@ describe('Document', () => {
await onLoadSuccessPromise;

const child = getByTestId(container, 'child');

expect(child.dataset.rotate).toBe('90');
});

Expand All @@ -389,6 +396,7 @@ describe('Document', () => {
await onLoadSuccessPromise;

const child = getByTestId(container, 'child');

expect(child.dataset.rendermode).toBe('canvas');
});

Expand All @@ -406,6 +414,7 @@ describe('Document', () => {
await onLoadSuccessPromise;

const child = getByTestId(container, 'child');

expect(child.dataset.rotate).toBe('180');
});
});
Expand Down
12 changes: 10 additions & 2 deletions src/Page/AnnotationLayer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('AnnotationLayer', () => {
);

expect.assertions(1);

await expect(onGetAnnotationsSuccessPromise).resolves.toMatchObject(desiredAnnotations);
});

Expand All @@ -67,6 +68,7 @@ describe('AnnotationLayer', () => {
);

expect.assertions(1);

await expect(onGetAnnotationsErrorPromise).resolves.toBeInstanceOf(Error);

restoreConsole();
Expand All @@ -85,6 +87,7 @@ describe('AnnotationLayer', () => {
);

expect.assertions(2);

await expect(onGetAnnotationsSuccessPromise).resolves.toMatchObject(desiredAnnotations);

const { func: onGetAnnotationsSuccess2, promise: onGetAnnotationsSuccessPromise2 } =
Expand Down Expand Up @@ -130,6 +133,7 @@ describe('AnnotationLayer', () => {
await onRenderAnnotationLayerSuccessPromise;

const annotationItems = [...container.firstElementChild.children];

expect(annotationItems).toHaveLength(desiredAnnotations.length);
});

Expand Down Expand Up @@ -232,8 +236,9 @@ describe('AnnotationLayer', () => {

const annotationLayer = container.firstElementChild;

// Expect the annotation layer to be rotated
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));
});
Expand All @@ -260,8 +265,9 @@ describe('AnnotationLayer', () => {

const annotationLayer = container.firstElementChild;

// Expect the annotation layer to be scaled
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));
});
Expand Down Expand Up @@ -292,6 +298,7 @@ describe('AnnotationLayer', () => {
await onRenderAnnotationLayerSuccessPromise;

const stringifiedAnnotationLayerNode = container.outerHTML;

expect(stringifiedAnnotationLayerNode).toMatch(desiredImageTagRegExp);
});

Expand Down Expand Up @@ -322,6 +329,7 @@ describe('AnnotationLayer', () => {
await onRenderAnnotationLayerSuccessPromise;

const stringifiedAnnotationLayerNode = container.outerHTML;

expect(stringifiedAnnotationLayerNode).toMatch(desiredImageTagRegExp);
});
});
Expand Down
6 changes: 6 additions & 0 deletions src/Page/TextLayer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('TextLayer', () => {
render(<TextLayer onGetTextSuccess={onGetTextSuccess} page={page} />);

expect.assertions(1);

await expect(onGetTextSuccessPromise).resolves.toMatchObject({ items: desiredTextItems });
});

Expand All @@ -51,6 +52,7 @@ describe('TextLayer', () => {
render(<TextLayer onGetTextError={onGetTextError} page={failingPage} />);

expect.assertions(1);

await expect(onGetTextErrorPromise).resolves.toBeInstanceOf(Error);

restoreConsole();
Expand All @@ -62,6 +64,7 @@ describe('TextLayer', () => {
const { rerender } = render(<TextLayer onGetTextSuccess={onGetTextSuccess} page={page} />);

expect.assertions(2);

await expect(onGetTextSuccessPromise).resolves.toMatchObject({
items: desiredTextItems,
});
Expand Down Expand Up @@ -98,6 +101,7 @@ describe('TextLayer', () => {
await onRenderTextLayerSuccessPromise;

const textItems = [...container.firstElementChild.children];

expect(textItems).toHaveLength(desiredTextItems.length + 1);
});

Expand All @@ -120,6 +124,7 @@ describe('TextLayer', () => {
await onRenderTextLayerSuccessPromise;

const textItems = [...container.firstElementChild.children];

expect(textItems).toHaveLength(desiredTextItems.length + 1);
});

Expand Down Expand Up @@ -176,6 +181,7 @@ describe('TextLayer', () => {
await onRenderTextLayerSuccessPromise;

const textItems = [...container.firstElementChild.children];

expect(textItems).toHaveLength(desiredTextItems.length + 1);

expect(customTextRenderer).toHaveBeenCalledTimes(desiredTextItems.length);
Expand Down

0 comments on commit d66b6b2

Please sign in to comment.