Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d818cfa

Browse filesBrowse files
edsadrItalo A. Casas
authored andcommitted
test: improve test-fs-write-stream-throw-type
* validate the errors for all assert.throws * use arrow functions PR-URL: #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>
1 parent 84bf04b commit d818cfa
Copy full SHA for d818cfa

File tree

Expand file treeCollapse file tree

1 file changed

+24
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-12
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-fs-write-stream-throw-type-error.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-write-stream-throw-type-error.js
+24-12Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,44 @@ const assert = require('assert');
44
const fs = require('fs');
55
const path = require('path');
66

7+
const numberError = new RegExp('^TypeError: "options" must be a string ' +
8+
'or an object, got number instead.$');
9+
10+
const booleanError = new RegExp('^TypeError: "options" must be a string ' +
11+
'or an object, got boolean instead.$');
12+
713
const example = path.join(common.tmpDir, 'dummy');
814

915
common.refreshTmpDir();
1016

11-
assert.doesNotThrow(function() {
17+
assert.doesNotThrow(() => {
1218
fs.createWriteStream(example, undefined);
1319
});
14-
assert.doesNotThrow(function() {
20+
21+
assert.doesNotThrow(() => {
1522
fs.createWriteStream(example, null);
1623
});
17-
assert.doesNotThrow(function() {
24+
25+
assert.doesNotThrow(() => {
1826
fs.createWriteStream(example, 'utf8');
1927
});
20-
assert.doesNotThrow(function() {
28+
29+
assert.doesNotThrow(() => {
2130
fs.createWriteStream(example, {encoding: 'utf8'});
2231
});
2332

24-
assert.throws(function() {
33+
assert.throws(() => {
2534
fs.createWriteStream(example, 123);
26-
}, /"options" must be a string or an object/);
27-
assert.throws(function() {
35+
}, numberError);
36+
37+
assert.throws(() => {
2838
fs.createWriteStream(example, 0);
29-
}, /"options" must be a string or an object/);
30-
assert.throws(function() {
39+
}, numberError);
40+
41+
assert.throws(() => {
3142
fs.createWriteStream(example, true);
32-
}, /"options" must be a string or an object/);
33-
assert.throws(function() {
43+
}, booleanError);
44+
45+
assert.throws(() => {
3446
fs.createWriteStream(example, false);
35-
}, /"options" must be a string or an object/);
47+
}, booleanError);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.