summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-write-stream-throw-type-error.js
diff options
context:
space:
mode:
authorAdrian Estrada <edsadr@gmail.com>2017-01-12 19:27:01 -0500
committerJames M Snell <jasnell@gmail.com>2017-01-16 10:45:35 -0800
commit1699a8ad71195bb3066630d38d16b1df7119a495 (patch)
tree0a5a00fe2130ce8860f7d3a015ffd75673fdd263 /test/parallel/test-fs-write-stream-throw-type-error.js
parent8628c9349905807b872f3c28ee6a7ff88b04f832 (diff)
downloadandroid-node-v8-1699a8ad71195bb3066630d38d16b1df7119a495.tar.gz
android-node-v8-1699a8ad71195bb3066630d38d16b1df7119a495.tar.bz2
android-node-v8-1699a8ad71195bb3066630d38d16b1df7119a495.zip
test: improve test-fs-write-stream-throw-type
* validate the errors for all assert.throws * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10779 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-fs-write-stream-throw-type-error.js')
-rw-r--r--test/parallel/test-fs-write-stream-throw-type-error.js36
1 files changed, 24 insertions, 12 deletions
diff --git a/test/parallel/test-fs-write-stream-throw-type-error.js b/test/parallel/test-fs-write-stream-throw-type-error.js
index 996b22119c..940def65b3 100644
--- a/test/parallel/test-fs-write-stream-throw-type-error.js
+++ b/test/parallel/test-fs-write-stream-throw-type-error.js
@@ -4,32 +4,44 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
+const numberError = new RegExp('^TypeError: "options" must be a string ' +
+ 'or an object, got number instead.$');
+
+const booleanError = new RegExp('^TypeError: "options" must be a string ' +
+ 'or an object, got boolean instead.$');
+
const example = path.join(common.tmpDir, 'dummy');
common.refreshTmpDir();
-assert.doesNotThrow(function() {
+assert.doesNotThrow(() => {
fs.createWriteStream(example, undefined);
});
-assert.doesNotThrow(function() {
+
+assert.doesNotThrow(() => {
fs.createWriteStream(example, null);
});
-assert.doesNotThrow(function() {
+
+assert.doesNotThrow(() => {
fs.createWriteStream(example, 'utf8');
});
-assert.doesNotThrow(function() {
+
+assert.doesNotThrow(() => {
fs.createWriteStream(example, {encoding: 'utf8'});
});
-assert.throws(function() {
+assert.throws(() => {
fs.createWriteStream(example, 123);
-}, /"options" must be a string or an object/);
-assert.throws(function() {
+}, numberError);
+
+assert.throws(() => {
fs.createWriteStream(example, 0);
-}, /"options" must be a string or an object/);
-assert.throws(function() {
+}, numberError);
+
+assert.throws(() => {
fs.createWriteStream(example, true);
-}, /"options" must be a string or an object/);
-assert.throws(function() {
+}, booleanError);
+
+assert.throws(() => {
fs.createWriteStream(example, false);
-}, /"options" must be a string or an object/);
+}, booleanError);