This repository was archived by the owner on Apr 12, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var PDFDocument = require ( '../lib/document' ) . default ;
2+ var PDFSecurity = require ( '../lib/security' ) . default ;
3+ var CryptoJS = require ( 'crypto-js' ) ;
24var path = require ( 'path' ) ;
35var fs = require ( 'fs' ) ;
46
7+ // manual mock for PDFSecurity to ensure stored id will be the same accross different systems
8+ PDFSecurity . generateFileID = ( ) => {
9+ return new Buffer ( 'mocked-pdf-id' ) ;
10+ }
11+
12+ PDFSecurity . generateRandomWordArray = ( bytes ) => {
13+ const words = [ ] ;
14+ for ( let i = 0 ; i < bytes ; i ++ ) {
15+ words . push ( 0x00010203 ) ;
16+ }
17+ return new CryptoJS . lib . WordArray . init ( words , bytes ) ;
18+ }
19+
520function updatePdf ( pdfData , testState , snapshotChanges ) {
621 const pdfDir = path . join ( path . dirname ( testState . testPath ) , '__pdfs__' ) ;
722 if ( ! fs . existsSync ( pdfDir ) ) {
Original file line number Diff line number Diff line change 11const PDFDocument = require ( '../../lib/document' ) . default ;
2+ const PDFSecurity = require ( '../../lib/security' ) . default ;
3+
4+ // manual mock for PDFSecurity to ensure stored id will be the same accross different systems
5+ PDFSecurity . generateFileID = ( ) => {
6+ return new Buffer ( 'mocked-pdf-id' ) ;
7+ }
28
39describe ( 'Document trailer' , ( ) => {
410 let document ;
@@ -28,7 +34,7 @@ describe('Document trailer', () => {
2834 ] ,
2935 [
3036 'trailer' ,
31- `<<\n/Size 11\n/Root 2 0 R\n/Info 7 0 R\n/ID [<8c72cf48ff87daac57e26bf1550e6979 > <8c72cf48ff87daac57e26bf1550e6979 >]\n>>`
37+ `<<\n/Size 11\n/Root 2 0 R\n/Info 7 0 R\n/ID [<6d6f636b65642d7064662d6964 > <6d6f636b65642d7064662d6964 >]\n>>`
3238 ]
3339 ] ;
3440 document . _write = function ( data ) {
You can’t perform that action at this time.
0 commit comments