test: added coverage for fs/promises API

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Mithun Sasidharan 2018-04-23 23:03:19 +05:30 committed by Ruben Bridgewater
parent 2fd248f639
commit 062a6e20e3
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -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());