From 7fbeebac9679f16b20e2fa9933e1c71410afe30f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 6 Jun 2017 09:53:32 -0700 Subject: [PATCH] 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 Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/parallel/test-fs-read-file-assert-encoding.js | 4 ++-- test/parallel/test-fs-read-type.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-fs-read-file-assert-encoding.js b/test/parallel/test-fs-read-file-assert-encoding.js index 929caf88bd4..ac0f45f98b3 100644 --- a/test/parallel/test-fs-read-file-assert-encoding.js +++ b/test/parallel/test-fs-read-file-assert-encoding.js @@ -8,6 +8,6 @@ const encoding = 'foo-8'; const filename = 'bar.txt'; assert.throws( - fs.readFile.bind(fs, filename, { encoding }, common.noop), - new RegExp(`Error: Unknown encoding: ${encoding}$`) + fs.readFile.bind(fs, filename, { encoding }, common.mustNotCall()), + new RegExp(`^Error: Unknown encoding: ${encoding}$`) ); diff --git a/test/parallel/test-fs-read-type.js b/test/parallel/test-fs-read-type.js index e62405c48ee..c6e3e53f054 100644 --- a/test/parallel/test-fs-read-type.js +++ b/test/parallel/test-fs-read-type.js @@ -13,9 +13,9 @@ assert.throws(() => { expected.length, 0, 'utf-8', - common.noop); -}, /Second argument needs to be a buffer/); + common.mustNotCall()); +}, /^TypeError: Second argument needs to be a buffer$/); assert.throws(() => { fs.readSync(fd, expected.length, 0, 'utf-8'); -}, /Second argument needs to be a buffer/); +}, /^TypeError: Second argument needs to be a buffer$/);