diff --git a/src/__tests__/volume.test.ts b/src/__tests__/volume.test.ts index 5f132e8e..75abb2ae 100644 --- a/src/__tests__/volume.test.ts +++ b/src/__tests__/volume.test.ts @@ -1444,4 +1444,29 @@ describe('volume', () => { }); }); }); + describe('.createReadStream', () => { + it('accepts filehandle as fd option', done => { + const vol = Volume.fromJSON({ + '/test.txt': 'Hello', + }); + vol.promises.open('/test.txt', 'r').then(fh => { + const readStream = vol.createReadStream( + '/this/should/be/ignored', + { fd: fh }, + ); + readStream.setEncoding('utf8'); + let readData = ''; + readStream.on('readable', () => { + const chunk = readStream.read(); + if (chunk != null) readData += chunk; + }); + readStream.on('end', () => { + expect(readData).toEqual('Hello'); + done(); + }); + }).catch((err) => { + expect(err).toBeNull(); + }); + }); + }); });