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: https://github.com/nodejs/node/pull/13501 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
6318078d2c
commit
7fbeebac96
@ -8,6 +8,6 @@ const encoding = 'foo-8';
|
|||||||
const filename = 'bar.txt';
|
const filename = 'bar.txt';
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
fs.readFile.bind(fs, filename, { encoding }, common.noop),
|
fs.readFile.bind(fs, filename, { encoding }, common.mustNotCall()),
|
||||||
new RegExp(`Error: Unknown encoding: ${encoding}$`)
|
new RegExp(`^Error: Unknown encoding: ${encoding}$`)
|
||||||
);
|
);
|
||||||
|
@ -13,9 +13,9 @@ assert.throws(() => {
|
|||||||
expected.length,
|
expected.length,
|
||||||
0,
|
0,
|
||||||
'utf-8',
|
'utf-8',
|
||||||
common.noop);
|
common.mustNotCall());
|
||||||
}, /Second argument needs to be a buffer/);
|
}, /^TypeError: Second argument needs to be a buffer$/);
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
fs.readSync(fd, expected.length, 0, 'utf-8');
|
fs.readSync(fd, expected.length, 0, 'utf-8');
|
||||||
}, /Second argument needs to be a buffer/);
|
}, /^TypeError: Second argument needs to be a buffer$/);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user