test: check error message in test-fs-make-callback
Add a RegExp to `throws` assertions. PR-URL: https://github.com/nodejs/node/pull/10914 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
087516a34e
commit
5614dc30dd
@ -2,6 +2,7 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const cbTypeError = /^TypeError: "callback" argument must be a function$/;
|
||||
|
||||
function test(cb) {
|
||||
return function() {
|
||||
@ -26,13 +27,13 @@ process.once('warning', common.mustCall((warning) => {
|
||||
assert.doesNotThrow(test());
|
||||
|
||||
function invalidArgumentsTests() {
|
||||
assert.throws(test(null));
|
||||
assert.throws(test(true));
|
||||
assert.throws(test(false));
|
||||
assert.throws(test(1));
|
||||
assert.throws(test(0));
|
||||
assert.throws(test('foo'));
|
||||
assert.throws(test(/foo/));
|
||||
assert.throws(test([]));
|
||||
assert.throws(test({}));
|
||||
assert.throws(test(null), cbTypeError);
|
||||
assert.throws(test(true), cbTypeError);
|
||||
assert.throws(test(false), cbTypeError);
|
||||
assert.throws(test(1), cbTypeError);
|
||||
assert.throws(test(0), cbTypeError);
|
||||
assert.throws(test('foo'), cbTypeError);
|
||||
assert.throws(test(/foo/), cbTypeError);
|
||||
assert.throws(test([]), cbTypeError);
|
||||
assert.throws(test({}), cbTypeError);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user