mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-12 21:21:04 +02:00
Merge pull request #21391 from Snuffleupagus/getDocument-Node-fs-unit-test
Add a unit-test for passing a filesystem URL-string (in Node.js) to `getDocument`
This commit is contained in:
commit
f4d6b4ef85
@ -228,6 +228,28 @@ describe("api", function () {
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("creates pdf doc from filesystem URL-string (in Node.js)", async function () {
|
||||
if (!isNodeJS) {
|
||||
pending("Testing Node.js functionality.");
|
||||
}
|
||||
const url = process.getBuiltinModule("url");
|
||||
const cwdURL = url.pathToFileURL(process.cwd()) + "/";
|
||||
const urlStr = new URL("./test/pdfs/basicapi.pdf", cwdURL).href;
|
||||
|
||||
const loadingTask = getDocument({ url: urlStr });
|
||||
expect(loadingTask).toBeInstanceOf(PDFDocumentLoadingTask);
|
||||
const pdfDocument = await loadingTask.promise;
|
||||
|
||||
expect(typeof urlStr).toEqual("string");
|
||||
expect(pdfDocument).toBeInstanceOf(PDFDocumentProxy);
|
||||
expect(pdfDocument.numPages).toEqual(3);
|
||||
|
||||
// Ensure that Node.js streaming was used to load the PDF document.
|
||||
expect(pdfDocument.getNetworkStreamName()).toEqual("PDFNodeStream");
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("creates pdf doc from URL and aborts before worker initialized", async function () {
|
||||
const loadingTask = getDocument(basicApiGetDocumentParams);
|
||||
expect(loadingTask).toBeInstanceOf(PDFDocumentLoadingTask);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user