@@ -36,6 +36,10 @@ const opts = {
3636 chunkSize : 1024 ,
3737} ;
3838
39+ const optsInfo = {
40+ info : true
41+ } ;
42+
3943for ( const [ type , expect ] of [
4044 [ 'string' , expectStr ] ,
4145 [ 'Buffer' , expectBuf ] ,
@@ -44,10 +48,10 @@ for (const [type, expect] of [
4448 )
4549] ) {
4650 for ( const method of [
47- [ 'gzip' , 'gunzip' ] ,
48- [ 'gzip' , 'unzip' ] ,
49- [ 'deflate' , 'inflate' ] ,
50- [ 'deflateRaw' , 'inflateRaw' ] ,
51+ [ 'gzip' , 'gunzip' , 'Gzip' , 'Gunzip' ] ,
52+ [ 'gzip' , 'unzip' , 'Gzip' , 'Unzip' ] ,
53+ [ 'deflate' , 'inflate' , 'Deflate' , 'Inflate' ] ,
54+ [ 'deflateRaw' , 'inflateRaw' , 'DeflateRaw' , 'InflateRaw' ] ,
5155 ] ) {
5256 zlib [ method [ 0 ] ] ( expect , opts , common . mustCall ( ( err , result ) => {
5357 zlib [ method [ 1 ] ] ( result , opts , common . mustCall ( ( err , result ) => {
@@ -65,6 +69,22 @@ for (const [type, expect] of [
6569 } ) ) ;
6670 } ) ) ;
6771
72+ zlib [ method [ 0 ] ] ( expect , optsInfo , common . mustCall ( ( err , result ) => {
73+ assert . ok ( result . engine instanceof zlib [ method [ 2 ] ] ,
74+ `Should get engine ${ method [ 2 ] } after ${ method [ 0 ] } ` +
75+ `${ type } with info option.` ) ;
76+
77+ const compressed = result . buffer ;
78+ zlib [ method [ 1 ] ] ( compressed , optsInfo , common . mustCall ( ( err , result ) => {
79+ assert . strictEqual ( result . buffer . toString ( ) , expectStr ,
80+ `Should get original string after ${ method [ 0 ] } /` +
81+ `${ method [ 1 ] } ${ type } with info option.` ) ;
82+ assert . ok ( result . engine instanceof zlib [ method [ 3 ] ] ,
83+ `Should get engine ${ method [ 3 ] } after ${ method [ 0 ] } ` +
84+ `${ type } with info option.` ) ;
85+ } ) ) ;
86+ } ) ) ;
87+
6888 {
6989 const compressed = zlib [ `${ method [ 0 ] } Sync` ] ( expect , opts ) ;
7090 const decompressed = zlib [ `${ method [ 1 ] } Sync` ] ( compressed , opts ) ;
@@ -81,5 +101,21 @@ for (const [type, expect] of [
81101 `Should get original string after ${ method [ 0 ] } Sync/` +
82102 `${ method [ 1 ] } Sync ${ type } without options.` ) ;
83103 }
104+
105+
106+ {
107+ const compressed = zlib [ `${ method [ 0 ] } Sync` ] ( expect , optsInfo ) ;
108+ assert . ok ( compressed . engine instanceof zlib [ method [ 2 ] ] ,
109+ `Should get engine ${ method [ 2 ] } after ${ method [ 0 ] } ` +
110+ `${ type } with info option.` ) ;
111+ const decompressed = zlib [ `${ method [ 1 ] } Sync` ] ( compressed . buffer ,
112+ optsInfo ) ;
113+ assert . strictEqual ( decompressed . buffer . toString ( ) , expectStr ,
114+ `Should get original string after ${ method [ 0 ] } Sync/` +
115+ `${ method [ 1 ] } Sync ${ type } without options.` ) ;
116+ assert . ok ( decompressed . engine instanceof zlib [ method [ 3 ] ] ,
117+ `Should get engine ${ method [ 3 ] } after ${ method [ 0 ] } ` +
118+ `${ type } with info option.` ) ;
119+ }
84120 }
85121}
0 commit comments