Skip to content

Commit 7906ed5

Browse files
andreicioromilalpinca
authored andcommitted
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>
1 parent 92f3b30 commit 7906ed5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎test/parallel/test-url-parse-invalid-input.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ const url = require('url');
1212
0.0,
1313
0,
1414
[],
15-
{}
16-
].forEach(function(val){
17-
assert.throws(function(){url.parse(val);},TypeError);
15+
{},
16+
()=>{},
17+
Symbol('foo')
18+
].forEach((val)=>{
19+
assert.throws(()=>{url.parse(val);},
20+
/^TypeError:Parameter"url"mustbeastring,not(undefined|boolean|number|object|function|symbol)$/);
1821
});
1922

20-
assert.throws(function(){url.parse('http://%E0%A4%A@fail');},/^URIError:URImalformed$/);
23+
assert.throws(()=>{url.parse('http://%E0%A4%A@fail');},
24+
/^URIError:URImalformed$/);

0 commit comments

Comments
 (0)