@@ -31,6 +31,18 @@ describe('imagesToPDF', () => {
3131 ` )
3232 } )
3333
34+ it ( 'should work for more than one image' , async ( ) => {
35+ const imagesToPDF = await import ( '../src' ) . then ( ( res ) => res . imagesToPDF )
36+ const pdf = await imagesToPDF ( [ ab , ab ] )
37+
38+ expect ( pdf ) . toMatchInlineSnapshot ( `
39+ Object {
40+ "arrayBuffer": [Function],
41+ "dataUrl": [Function],
42+ }
43+ ` )
44+ } )
45+
3446 describe ( 'imagesToPDF:dataUrl' , ( ) => {
3547 it ( 'should return data url string' , async ( ) => {
3648 const imagesToPDF = await import ( '../src' ) . then ( ( res ) => res . imagesToPDF )
@@ -53,4 +65,17 @@ describe('imagesToPDF', () => {
5365 expect ( isPdf ( new Uint8Array ( pdf . arrayBuffer ( ) ) ) ) . toBe ( true )
5466 } )
5567 } )
68+
69+ describe ( 'ImagesToPdf' , ( ) => {
70+ test ( 'addImage method should work' , async ( ) => {
71+ const ImagesToPdf = await import ( '../src' ) . then ( ( res ) => res . default )
72+ const pdf = new ImagesToPdf ( )
73+ pdf . addImage ( ab , { height : 20 , width : 20 } )
74+ pdf . addImage ( new Uint8Array ( ab ) , { height : 20 } )
75+
76+ expect ( pdf . images . length ) . toBe ( 2 )
77+ const arb = ( await pdf . createPdf ( ) ) . arrayBuffer ( )
78+ expect ( isPdf ( new Uint8Array ( arb ) ) ) . toBe ( true )
79+ } )
80+ } )
5681} )
0 commit comments