Permalink
Browse files

test: add regex check in test-url-parse-invalid-input

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 7, 2017
1 parent 92f3b30 commit 7906ed50fab6d3e8f6bd259484c465f2df1bc754
Showing with 8 additions and 4 deletions.
  1. +8 −4 test/parallel/test-url-parse-invalid-input.js
@@ -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.