summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-write-stream.js
diff options
context:
space:
mode:
authorSteven <steven@ceriously.com>2017-12-17 14:55:22 -0500
committerJoyee Cheung <joyeec9h3@gmail.com>2017-12-24 01:42:59 +0800
commit8599465d33b16b12da844f115fd10f9af4ad530f (patch)
tree60237fc19b6439b7331c83f261949d0dd185d2af /test/parallel/test-fs-write-stream.js
parentae2bed993884573f88da906d435c992e445c3834 (diff)
downloadnode-new-8599465d33b16b12da844f115fd10f9af4ad530f.tar.gz
fs: migrate errors to internal/errors
Throw ERR_INVALID_ARG_TYPE when validating arguments passed to WriteStream.prototype._write. Refs: https://github.com/nodejs/node/issues/17709 PR-URL: https://github.com/nodejs/node/pull/17719 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-write-stream.js')
-rw-r--r--test/parallel/test-fs-write-stream.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/parallel/test-fs-write-stream.js b/test/parallel/test-fs-write-stream.js
index bba2debf91..1dc25547a9 100644
--- a/test/parallel/test-fs-write-stream.js
+++ b/test/parallel/test-fs-write-stream.js
@@ -49,3 +49,16 @@ common.refreshTmpDir();
});
stream.destroy();
}
+
+// Throws if data is not of type Buffer.
+{
+ const stream = fs.createWriteStream(file);
+ common.expectsError(() => {
+ stream._write(42, null, function() {});
+ }, {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "data" argument must be of type Buffer. Received type number'
+ });
+ stream.destroy();
+}