From 61a56fe437fcc90e7d0cc6839ea42eb3d4011f8e Mon Sep 17 00:00:00 2001 From: Mithun Sasidharan Date: Mon, 23 Apr 2018 23:03:19 +0530 Subject: [PATCH] test: added coverage for fs/promises API PR-URL: https://github.com/nodejs/node/pull/20219 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Tiancheng "Timothy" Gu --- .../test-fs-promises-file-handle-write.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-fs-promises-file-handle-write.js b/test/parallel/test-fs-promises-file-handle-write.js index 842095a214c2ef..b5c83a169021c2 100644 --- a/test/parallel/test-fs-promises-file-handle-write.js +++ b/test/parallel/test-fs-promises-file-handle-write.js @@ -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());