Skip to content

Commit

Permalink
test: check error message in test-fs-make-callback
Browse files Browse the repository at this point in the history
Add a RegExp to `throws` assertions.

PR-URL: #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>
  • Loading branch information
legalcodes authored and targos committed Jan 24, 2017
1 parent 087516a commit 5614dc3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/parallel/test-fs-make-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}

0 comments on commit 5614dc3

Please sign in to comment.