Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: added coverage for fs/promises API
  • Loading branch information
mithunsasidharan committed Apr 23, 2018
commit c2e10618086868d9054d6bf92ea2d5ee35d55ae1
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());