Skip to content

Commit

Permalink
Added PDF/UA metadata unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiaugustin committed Dec 15, 2023
1 parent 44ed491 commit 3906db0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/unit/pdfua.spec.js
Original file line number Diff line number Diff line change
@@ -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');
});

});

0 comments on commit 3906db0

Please sign in to comment.