From 3906db0f0e008e5e0b77f09025412736f1034d7d Mon Sep 17 00:00:00 2001 From: Andrei Augustin Date: Fri, 15 Dec 2023 17:52:34 +0200 Subject: [PATCH] Added PDF/UA metadata unit tests --- tests/unit/pdfua.spec.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/unit/pdfua.spec.js diff --git a/tests/unit/pdfua.spec.js b/tests/unit/pdfua.spec.js new file mode 100644 index 00000000..28e3e4f6 --- /dev/null +++ b/tests/unit/pdfua.spec.js @@ -0,0 +1,37 @@ +import PDFDocument from '../../lib/document'; +import { logData } from './helpers'; + +describe('PDF/UA', () => { + + test('metadata is present', () => { + let options = { + autoFirstPage: false, + pdfVersion: '1.7', + subset: 'PDF/UA', + tagged: true + }; + let doc = new PDFDocument(options); + const data = logData(doc); + doc.end(); + expect(data).toContainChunk([ + `11 0 obj`, + `<<\n/length 841\n/Type /Metadata\n/Subtype /XML\n/Length 843\n>>` + ]); + }); + + test('metadata constains pdfuaid part', () => { + let options = { + autoFirstPage: false, + pdfVersion: '1.7', + subset: 'PDF/UA', + tagged: true + }; + let doc = new PDFDocument(options); + const data = logData(doc); + doc.end(); + let metadata = Buffer.from(data[24]).toString(); + + expect(metadata).toContain('pdfuaid:part>1'); + }); + +}); \ No newline at end of file