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: #12879
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: David Cai <davidcai1993@yahoo.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
andreicioromila authored and lpinca committed May 16, 2017
1 parent 92f3b30 commit 7906ed5
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 7906ed5

Please sign in to comment.