0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-url-parse-invalid-input.js
starkwang 473f0eff29 errors,url: port url errors to internal/errors
PR-URL: https://github.com/nodejs/node/pull/13963
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-01 22:32:32 -04:00

29 lines
744 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const url = require('url');
// https://github.com/joyent/node/issues/568
[
[undefined, 'undefined'],
[null, 'null'],
[true, 'boolean'],
[false, 'boolean'],
[0.0, 'number'],
[0, 'number'],
[[], 'object'],
[{}, 'object'],
[() => {}, 'function'],
[Symbol('foo'), 'symbol']
].forEach(([val, type]) => {
const error = common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: `The "url" argument must be of type string. Received type ${type}`
});
assert.throws(() => { url.parse(val); }, error);
});
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
/^URIError: URI malformed$/);