Skip to content

Commit c8db047

Browse files
Trottaddaleax
authored andcommitted
test: refactor test-fs-read-*
* Use `common.mustNotCall()` in place of `common.noop` where appropriate * Increase specificity of regular expressions (that is, make them match the whole error string rather than part of the error string) in `assert.throws()` calls PR-URL: #13501 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent bf61d97 commit c8db047

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/parallel/test-fs-read-file-assert-encoding.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ const encoding = 'foo-8';
88
const filename = 'bar.txt';
99

1010
assert.throws(
11-
fs.readFile.bind(fs, filename, { encoding }, common.noop),
12-
new RegExp(`Error: Unknown encoding: ${encoding}$`)
11+
fs.readFile.bind(fs, filename, { encoding }, common.mustNotCall()),
12+
new RegExp(`^Error: Unknown encoding: ${encoding}$`)
1313
);

test/parallel/test-fs-read-type.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ assert.throws(() => {
1313
expected.length,
1414
0,
1515
'utf-8',
16-
common.noop);
17-
}, /Second argument needs to be a buffer/);
16+
common.mustNotCall());
17+
}, /^TypeError: Second argument needs to be a buffer$/);
1818

1919
assert.throws(() => {
2020
fs.readSync(fd, expected.length, 0, 'utf-8');
21-
}, /Second argument needs to be a buffer/);
21+
}, /^TypeError: Second argument needs to be a buffer$/);

0 commit comments

Comments
 (0)