-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/placeholder-plain/src/__snapshots__/createBufferTrailer.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`createBufferTrailer creates expected outputs 1`] = ` | ||
"xref | ||
0 1 | ||
0000000000 65535 f | ||
trailer | ||
<< | ||
/Size 3 | ||
/Root 1 0 R | ||
/Info 2 0 R | ||
/Prev 4220 | ||
>> | ||
startxref | ||
4654 | ||
%%EOF" | ||
`; | ||
|
||
exports[`createBufferTrailer creates expected outputs 2`] = ` | ||
"xref | ||
0 1 | ||
0000000000 65535 f | ||
trailer | ||
<< | ||
/Size 3 | ||
/Root 1 0 R | ||
/Prev 4220 | ||
>> | ||
startxref | ||
4654 | ||
%%EOF" | ||
`; | ||
|
||
exports[`createBufferTrailer creates expected outputs 3`] = ` | ||
"xref | ||
0 1 | ||
0000000000 65535 f | ||
3 1 | ||
0000004077 00000 n | ||
4 1 | ||
0000003812 00000 n | ||
trailer | ||
<< | ||
/Size 3 | ||
/Root 1 0 R | ||
/Prev 4220 | ||
>> | ||
startxref | ||
4654 | ||
%%EOF" | ||
`; |
36 changes: 36 additions & 0 deletions
36
packages/placeholder-plain/src/createBufferTrailer.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {readTestResource} from '@signpdf/internal-utils'; | ||
import createBufferTrailer from './createBufferTrailer'; | ||
|
||
describe(createBufferTrailer, () => { | ||
it('creates expected outputs', () => { | ||
const pdfBuffer = readTestResource('signed.pdf'); | ||
|
||
/** @type {import("./readPdf").ReadPdfReturnType} */ | ||
const info = { | ||
xref: { | ||
startingIndex: 0, | ||
maxIndex: 2, | ||
offsets: new Map([ | ||
[1, 4163], | ||
[2, 4098], | ||
]), | ||
}, | ||
rootRef: '1 0 R', | ||
root: '\n/Type /Catalog\n/Pages 1 0 R\n/AcroForm 9 0 R\n', | ||
infoRef: '2 0 R', | ||
trailerStart: 4510, | ||
previousXrefs: [], | ||
xRefPosition: 4220, | ||
}; | ||
const addedReferences = new Map(); | ||
|
||
expect(createBufferTrailer(pdfBuffer, info, addedReferences).toString()).toMatchSnapshot(); | ||
|
||
info.infoRef = undefined; | ||
expect(createBufferTrailer(pdfBuffer, info, addedReferences).toString()).toMatchSnapshot(); | ||
|
||
addedReferences.set(3, 4077); | ||
addedReferences.set(4, 3812); | ||
expect(createBufferTrailer(pdfBuffer, info, addedReferences).toString()).toMatchSnapshot(); | ||
}); | ||
}); |