Skip to content

Commit

Permalink
add test for createWriteStream accepting fh as fd
Browse files Browse the repository at this point in the history
  • Loading branch information
graue committed Nov 28, 2024
1 parent b426edd commit 21f729d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/__tests__/volume.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { promisify } from 'util';
import { URL } from 'url';
import { Link } from '../node';
import Stats from '../Stats';
Expand Down Expand Up @@ -1431,4 +1432,16 @@ describe('volume', () => {
expect(new StatWatcher(vol).vol).toBe(vol);
});
});
describe('.createWriteStream', () => {
it('accepts filehandle as fd option', async () => {
const vol = new Volume();
const fh = await vol.promises.open('/test.txt', 'wx', 0o600);
const writeStream = vol.createWriteStream('', { fd: fh });
await promisify(writeStream.write.bind(writeStream))(Buffer.from('Hello'));
await promisify(writeStream.close.bind(writeStream))();
expect(vol.toJSON()).toEqual({
'/test.txt': 'Hello',
});
});
});
});

0 comments on commit 21f729d

Please sign in to comment.