Skip to content
Snippets Groups Projects

Draft: Resolve "[Document Sealing] Implement PDF parser"

Open Zdravko Iliev requested to merge 1-document-sealing-implement-pdf-parser into master
Compare and Show latest version
28 files
+ 1989
1593
Compare changes
  • Side-by-side
  • Inline
Files
28
+ 22
3
@@ -2,9 +2,10 @@ import fs from "fs";
import path from "path";
import { describe, it, expect } from "@jest/globals";
import PDFparser from "../src/pdfParser";
import { AppError } from "../src/lib/errors";
describe("PDF parser", () => {
it("should return pdf document metadata", async () => {
it("should return pdf document metadata including signatures", async () => {
const file = fs.readFileSync(
path.resolve(__dirname, "./abacus-two-signatures.pdf")
);
@@ -12,8 +13,26 @@ describe("PDF parser", () => {
const parser = new PDFparser(file);
const actual = await parser.getPDFMeta();
console.log(actual);
expect(actual.pages).toEqual(2);
});
it("should return pdf document metadata without signatures", async () => {
const file = fs.readFileSync(path.resolve(__dirname, "./example.pdf"));
const parser = new PDFparser(file);
const actual = await parser.getPDFMeta();
expect(actual.pages).toEqual(1);
expect(actual.title).toEqual("PDF Digital Signatures");
expect(actual.author).toEqual("Tecxoft");
});
it("should throw error without file", async () => {
try {
const parser = new PDFparser(null);
const actual = await parser.getPDFMeta();
} catch (error) {
expect(error).toBeInstanceOf(AppError);
}
});
});
Loading