]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Chore: resolve dynamic import warnings from pdfjs, again (#9924)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 13 May 2025 04:04:18 +0000 (21:04 -0700)
committerGitHub <noreply@github.com>
Tue, 13 May 2025 04:04:18 +0000 (21:04 -0700)
src-ui/__mocks__/pdfjs-dist.ts [new file with mode: 0644]
src-ui/setup-jest.ts

diff --git a/src-ui/__mocks__/pdfjs-dist.ts b/src-ui/__mocks__/pdfjs-dist.ts
new file mode 100644 (file)
index 0000000..e975a40
--- /dev/null
@@ -0,0 +1,13 @@
+export const getDocument = jest.fn(() => ({
+  promise: Promise.resolve({ numPages: 3 }),
+}))
+
+export const GlobalWorkerOptions = { workerSrc: '' }
+export const VerbosityLevel = { ERRORS: 0 }
+
+globalThis.pdfjsLib = {
+  getDocument,
+  GlobalWorkerOptions,
+  VerbosityLevel,
+  AbortException: class AbortException extends Error {},
+}
index 162884feb7740fa6fd4e1589025f863375813ed7..6ac94a275d6e892e6e0506925b078c70c3c29165 100644 (file)
@@ -121,19 +121,4 @@ HTMLCanvasElement.prototype.getContext = <
   typeof HTMLCanvasElement.prototype.getContext
 >jest.fn()
 
-// pdfjs
-jest.mock('pdfjs-dist', () => ({
-  getDocument: jest.fn(() => ({
-    promise: Promise.resolve({ numPages: 3 }),
-  })),
-  GlobalWorkerOptions: { workerSrc: '' },
-  VerbosityLevel: { ERRORS: 0 },
-  globalThis: {
-    pdfjsLib: {
-      GlobalWorkerOptions: {
-        workerSrc: '',
-      },
-    },
-  },
-}))
-jest.mock('pdfjs-dist/web/pdf_viewer', () => ({}))
+jest.mock('pdfjs-dist')