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:
parent
2fd248f639
commit
062a6e20e3
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user