Browse Source

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>
v6
Rich Trott 8 years ago
parent
commit
7fbeebac96
  1. 4
      test/parallel/test-fs-read-file-assert-encoding.js
  2. 6
      test/parallel/test-fs-read-type.js

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

@ -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}$`)
); );

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

@ -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…
Cancel
Save