11'use strict' ;
2- const common = require ( '../common' ) ;
2+ require ( '../common' ) ;
33const assert = require ( 'assert' ) ;
4+ const test = require ( 'node:test' ) ;
45const { DecompressionStream, CompressionStream } = require ( 'stream/web' ) ;
56
67// Minimal gzip-compressed bytes for "hello"
@@ -9,7 +10,7 @@ const compressedGzip = new Uint8Array([
910 203 , 72 , 205 , 201 , 201 , 7 , 0 , 134 , 166 , 16 , 54 , 5 , 0 , 0 , 0 ,
1011] ) ;
1112
12- async function testDecompressionAcceptsArrayBuffer ( ) {
13+ test ( 'DecompressionStream accepts ArrayBuffer chunks' , async ( ) => {
1314 const ds = new DecompressionStream ( 'gzip' ) ;
1415 const reader = ds . readable . getReader ( ) ;
1516 const writer = ds . writable . getWriter ( ) ;
@@ -27,15 +28,13 @@ async function testDecompressionAcceptsArrayBuffer() {
2728 await writePromise ;
2829 const out = Buffer . concat ( chunks . map ( ( c ) => Buffer . from ( c ) ) ) ;
2930 assert . strictEqual ( out . toString ( ) , 'hello' ) ;
30- }
31+ } ) ;
3132
32- async function testCompressionRoundTripWithArrayBuffer ( ) {
33+ test ( 'CompressionStream round-trip with ArrayBuffer input' , async ( ) => {
3334 const cs = new CompressionStream ( 'gzip' ) ;
3435 const ds = new DecompressionStream ( 'gzip' ) ;
3536
3637 const csWriter = cs . writable . getWriter ( ) ;
37- const csReader = cs . readable . getReader ( ) ;
38- const dsWriter = ds . writable . getWriter ( ) ;
3938 const dsReader = ds . readable . getReader ( ) ;
4039
4140 const input = new TextEncoder ( ) . encode ( 'hello' ) . buffer ;
@@ -46,17 +45,12 @@ async function testCompressionRoundTripWithArrayBuffer() {
4645 await cs . readable . pipeTo ( ds . writable ) ;
4746
4847 const out = [ ] ;
49- done = false ;
48+ let done = false ;
5049 while ( ! done ) {
5150 const { value, done : d } = await dsReader . read ( ) ;
5251 if ( value ) out . push ( value ) ;
5352 done = d ;
5453 }
5554 const result = Buffer . concat ( out . map ( ( c ) => Buffer . from ( c ) ) ) ;
5655 assert . strictEqual ( result . toString ( ) , 'hello' ) ;
57- }
58-
59- Promise . all ( [
60- testDecompressionAcceptsArrayBuffer ( ) ,
61- testCompressionRoundTripWithArrayBuffer ( ) ,
62- ] ) . then ( common . mustCall ( ) ) ;
56+ } ) ;
0 commit comments