Skip to content

Commit

Permalink
test: add regex check in test-url-parse-invalid-input
Browse files Browse the repository at this point in the history
Use a regex to validate the error message.

PR-URL: nodejs#12879
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: David Cai <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
andreicioromila authored and Olivier Martin committed May 19, 2017
1 parent 3e5131b commit 4a61952
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/parallel/test-url-parse-invalid-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ const url = require('url');
0.0,
0,
[],
{}
].forEach(function(val) {
assert.throws(function() { url.parse(val); }, TypeError);
{},
() => {},
Symbol('foo')
].forEach((val) => {
assert.throws(() => { url.parse(val); },
/^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object|function|symbol)$/);
});

assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/);
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
/^URIError: URI malformed$/);

0 comments on commit 4a61952

Please sign in to comment.