From c01d934d3d878ec2dee6001d9da8d5b1eea3c419 Mon Sep 17 00:00:00 2001 From: Patrick Heneise Date: Wed, 15 Nov 2017 16:23:32 +0100 Subject: [PATCH] test: fs.write() if 3rd argument is a callback, not offset Easier way to resolve conflicts from #16822 and #16827. PR-URL: https://github.com/nodejs/node/pull/17045 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- test/parallel/test-fs-write.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js index e861b183d966f2..ccf2d9b40f7934 100644 --- a/test/parallel/test-fs-write.js +++ b/test/parallel/test-fs-write.js @@ -26,6 +26,7 @@ const path = require('path'); const fs = require('fs'); const fn = path.join(common.tmpDir, 'write.txt'); const fn2 = path.join(common.tmpDir, 'write2.txt'); +const fn3 = path.join(common.tmpDir, 'write3.txt'); const expected = 'ümlaut.'; const constants = fs.constants; @@ -73,3 +74,15 @@ fs.open(fn2, args, 0o644, common.mustCall((err, fd) => { fs.write(fd, '', 0, 'utf8', written); fs.write(fd, expected, 0, 'utf8', done); })); + +fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) { + assert.ifError(err); + + const done = common.mustCall(function(err, written) { + assert.ifError(err); + assert.strictEqual(Buffer.byteLength(expected), written); + fs.closeSync(fd); + }); + + fs.write(fd, expected, done); +}));