From c2e10618086868d9054d6bf92ea2d5ee35d55ae1 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 --- .../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());