Skip to content

Commit

Permalink
test: added coverage for fs/promises API
Browse files Browse the repository at this point in the history
PR-URL: #20219
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
  • Loading branch information
mithunsasidharan authored and MylesBorins committed May 4, 2018
1 parent 1385ffc commit 61a56fe
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/parallel/test-fs-promises-file-handle-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ async function validateEmptyWrite() {
assert.deepStrictEqual(buffer, readFileData);
}

validateWrite()
.then(validateEmptyWrite)
.then(common.mustCall());
async function validateNonUint8ArrayWrite() {
const filePathForHandle = path.resolve(tmpDir, 'tmp-data-write.txt');
const fileHandle = await open(filePathForHandle, 'w+');
const buffer = Buffer.from('Hello world', 'utf8').toString('base64');

await fileHandle.write(buffer, 0, buffer.length);
const readFileData = fs.readFileSync(filePathForHandle);
assert.deepStrictEqual(Buffer.from(buffer, 'utf8'), readFileData);
}

Promise.all([
validateWrite(),
validateEmptyWrite(),
validateNonUint8ArrayWrite()
]).then(common.mustCall());

0 comments on commit 61a56fe

Please sign in to comment.