Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Sep 18, 2024
1 parent 70b5e6d commit 55b7b16
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/react-pdf/src/Document.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,18 @@ describe('Document', () => {
vi.mocked(globalThis.console.error).mockRestore();
});

it('does not throw an error on unmount if loading has not yet finished', async () => {
const { func: onLoadProgress, promise: onLoadProgressPromise } = makeAsyncCallback();

const { unmount } = render(
<Document file={pdfFile} onLoadProgress={onLoadProgress} options={{ stopAtErrors: true }} />,
);

await onLoadProgressPromise;

expect(unmount).not.toThrowError();
});

it('warns if file prop was not memoized', () => {
const spy = vi.spyOn(globalThis.console, 'error').mockImplementation(() => {
// Intentionally empty
Expand Down

0 comments on commit 55b7b16

Please sign in to comment.