Browse Source

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

Use a regex to validate the error message.

PR-URL: https://github.com/nodejs/node/pull/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>
v6
Andrei Cioromila 8 years ago
committed by Luigi Pinca
parent
commit
7906ed50fa
  1. 12
      test/parallel/test-url-parse-invalid-input.js

12
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$/);

Loading…
Cancel
Save