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 authored and Myles Borins committed 2018-05-04 11:51:12 -04:00
1 parent 1385ffcccf
commit 61a56fe437
1 file changed
+15 -3
@@ -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());