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 26a73cc
Show file tree
Hide file tree
Showing 5 changed files with 37 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
6 changes: 6 additions & 0 deletions src/Outline.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('Outline', () => {
render(<Outline onLoadSuccess={onLoadSuccess} pdf={pdf} />);

expect.assertions(1);

await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedOutline);
});

Expand All @@ -47,6 +48,7 @@ describe('Outline', () => {
render(<Outline onLoadError={onLoadError} pdf={failingPdf} />);

expect.assertions(1);

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

restoreConsole();
Expand All @@ -58,6 +60,7 @@ describe('Outline', () => {
const { rerender } = render(<Outline onLoadSuccess={onLoadSuccess} pdf={pdf} />);

expect.assertions(2);

await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedOutline);

const { func: onLoadSuccess2, promise: onLoadSuccessPromise2 } = makeAsyncCallback();
Expand Down Expand Up @@ -88,6 +91,7 @@ describe('Outline', () => {
);

expect.assertions(1);

await onLoadSuccessPromise;

const wrapper = container.querySelector('.react-pdf__Outline');
Expand All @@ -103,6 +107,7 @@ describe('Outline', () => {
render(<Outline inputRef={inputRef} onLoadSuccess={onLoadSuccess} pdf={pdf} />);

expect.assertions(2);

await onLoadSuccessPromise;

expect(inputRef).toHaveBeenCalled();
Expand All @@ -115,6 +120,7 @@ describe('Outline', () => {
render(<Outline onLoadSuccess={onLoadSuccess} pdf={pdf} />);

expect.assertions(1);

await onLoadSuccessPromise;

const items = screen.getAllByRole('listitem');
Expand Down
6 changes: 6 additions & 0 deletions src/Page.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Page', () => {
render(<Page onLoadSuccess={onLoadSuccess} pageIndex={0} pdf={pdf} />);

expect.assertions(1);

await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPage);
});

Expand Down Expand Up @@ -89,6 +90,7 @@ describe('Page', () => {
render(<Page onLoadError={onLoadError} pageIndex={0} pdf={failingPdf} />);

expect.assertions(1);

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

restoreConsole();
Expand Down Expand Up @@ -124,6 +126,7 @@ describe('Page', () => {
render(<Page pageIndex={0} pdf={pdf} registerPage={registerPage} />);

expect.assertions(1);

await expect(registerPagePromise).resolves.toMatchObject(registerPageArguments);
});

Expand All @@ -135,6 +138,7 @@ describe('Page', () => {
unmount();

expect.assertions(1);

await expect(nuregisterPagePromise).resolves.toBe(unregisterPageArguments);
});

Expand All @@ -144,6 +148,7 @@ describe('Page', () => {
const { rerender } = render(<Page onLoadSuccess={onLoadSuccess} pageIndex={0} pdf={pdf} />);

expect.assertions(2);

await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPage);

const { func: onLoadSuccess2, promise: onLoadSuccessPromise2 } = makeAsyncCallback();
Expand All @@ -159,6 +164,7 @@ describe('Page', () => {
const { rerender } = render(<Page onLoadSuccess={onLoadSuccess} pageIndex={0} pdf={pdf} />);

expect.assertions(2);

await expect(onLoadSuccessPromise).resolves.toMatchObject(desiredLoadedPage);

const { func: onLoadSuccess2, promise: onLoadSuccessPromise2 } = makeAsyncCallback();
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 26a73cc

Please sign in to comment.