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 <[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]>
1 parent 92f3b30 commit 7906ed5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

+8-4
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" must be a string, not (undefined|boolean|number|object|function|symbol)$/);
1821
});
1922

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

0 commit comments

Comments
 (0)