mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Add unit tests for trailer
This commit is contained in:
parent
2651a74012
commit
c400dfa9e6
48
tests/unit/trailer.spec.js
Normal file
48
tests/unit/trailer.spec.js
Normal file
@ -0,0 +1,48 @@
|
||||
const PDFDocument = require('../../');
|
||||
|
||||
describe('Document trailer', () => {
|
||||
let document;
|
||||
|
||||
beforeEach(() => {
|
||||
document = new PDFDocument({info: { CreationDate: new Date(Date.UTC(2018,1,1)) } });
|
||||
});
|
||||
|
||||
test('', (done) => {
|
||||
const dataLog = [];
|
||||
const expected = [
|
||||
[
|
||||
'7 0 obj',
|
||||
'<<\n/Producer 8 0 R\n/Creator 9 0 R\n/CreationDate 10 0 R\n>>'
|
||||
],
|
||||
[
|
||||
'8 0 obj',
|
||||
'(PDFKit)'
|
||||
],
|
||||
[
|
||||
'9 0 obj',
|
||||
'(PDFKit)'
|
||||
],
|
||||
[
|
||||
'10 0 obj',
|
||||
'(D:20180201000000Z)'
|
||||
],
|
||||
[
|
||||
'trailer',
|
||||
`<<\n/Size 11\n/Root 2 0 R\n/Info 7 0 R\n/ID [<8c72cf48ff87daac57e26bf1550e6979> <8c72cf48ff87daac57e26bf1550e6979>]\n>>`
|
||||
]
|
||||
];
|
||||
document._write = function(data) {
|
||||
dataLog.push(data)
|
||||
}
|
||||
document.end();
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < expected.length; ++i) {
|
||||
let idx = dataLog.indexOf(expected[i][0]);
|
||||
for (let j = 1; j < expected[i].length; ++j) {
|
||||
expect(dataLog[idx + j]).toEqual(expected[i][j]);
|
||||
}
|
||||
}
|
||||
done();
|
||||
}, 1);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user