Skip to content

Commit 61a56fe

Browse files
mithunsasidharanMylesBorins
authored andcommitted
test: added coverage for fs/promises API
PR-URL: #20219 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
1 parent 1385ffc commit 61a56fe

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

test/parallel/test-fs-promises-file-handle-write.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ async function validateEmptyWrite() {
3535
assert.deepStrictEqual(buffer, readFileData);
3636
}
3737

38-
validateWrite()
39-
.then(validateEmptyWrite)
40-
.then(common.mustCall());
38+
async function validateNonUint8ArrayWrite() {
39+
const filePathForHandle = path.resolve(tmpDir, 'tmp-data-write.txt');
40+
const fileHandle = await open(filePathForHandle, 'w+');
41+
const buffer = Buffer.from('Hello world', 'utf8').toString('base64');
42+
43+
await fileHandle.write(buffer, 0, buffer.length);
44+
const readFileData = fs.readFileSync(filePathForHandle);
45+
assert.deepStrictEqual(Buffer.from(buffer, 'utf8'), readFileData);
46+
}
47+
48+
Promise.all([
49+
validateWrite(),
50+
validateEmptyWrite(),
51+
validateNonUint8ArrayWrite()
52+
]).then(common.mustCall());

0 commit comments

Comments
 (0)