-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(helpers): move helper that tests for errors to separate file
- Loading branch information
1 parent
6d6125e
commit f2e6312
Showing
2 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var values = [ | ||
undefined, | ||
null, | ||
0, | ||
1, | ||
true, | ||
false, | ||
{}, | ||
[], | ||
function() {}, | ||
new Date() | ||
]; | ||
|
||
/** | ||
* Calls parser with invalid arguments. | ||
* | ||
* @param {Function} parser - The parser. | ||
* @param {Function} [assert] - The assertion module. | ||
*/ | ||
function throwsError(parser, assert) { | ||
if (typeof assert !== 'function') { | ||
assert = require('assert'); | ||
} | ||
|
||
values.forEach(function(value) { | ||
it('throws error for argument: ' + value, function() { | ||
assert.throws(function() { | ||
parser(value); | ||
}, TypeError); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = throwsError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters