@@ -36,6 +36,10 @@ const opts = {
36
36
chunkSize : 1024 ,
37
37
} ;
38
38
39
+ const optsInfo = {
40
+ info : true
41
+ } ;
42
+
39
43
for ( const [ type , expect ] of [
40
44
[ 'string' , expectStr ] ,
41
45
[ 'Buffer' , expectBuf ] ,
@@ -44,10 +48,10 @@ for (const [type, expect] of [
44
48
)
45
49
] ) {
46
50
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' ] ,
51
55
] ) {
52
56
zlib [ method [ 0 ] ] ( expect , opts , common . mustCall ( ( err , result ) => {
53
57
zlib [ method [ 1 ] ] ( result , opts , common . mustCall ( ( err , result ) => {
@@ -65,6 +69,22 @@ for (const [type, expect] of [
65
69
} ) ) ;
66
70
} ) ) ;
67
71
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
+
68
88
{
69
89
const compressed = zlib [ `${ method [ 0 ] } Sync` ] ( expect , opts ) ;
70
90
const decompressed = zlib [ `${ method [ 1 ] } Sync` ] ( compressed , opts ) ;
@@ -81,5 +101,21 @@ for (const [type, expect] of [
81
101
`Should get original string after ${ method [ 0 ] } Sync/` +
82
102
`${ method [ 1 ] } Sync ${ type } without options.` ) ;
83
103
}
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
+ }
84
120
}
85
121
}
0 commit comments