mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 03:12:57 +00:00

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>
27 lines
720 B
JavaScript
27 lines
720 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const url = require('url');
|
|
|
|
const throwsObjsAndReportTypes = new Map([
|
|
[undefined, 'undefined'],
|
|
[null, 'null'],
|
|
[true, 'boolean'],
|
|
[false, 'boolean'],
|
|
[0, 'number'],
|
|
[function() {}, 'function'],
|
|
[Symbol('foo'), 'symbol']
|
|
]);
|
|
|
|
for (const [obj, type] of throwsObjsAndReportTypes) {
|
|
const error = common.expectsError({
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "urlObj" argument must be of type object. ' +
|
|
`Received type ${type}`
|
|
});
|
|
assert.throws(function() { url.format(obj); }, error);
|
|
}
|
|
assert.strictEqual(url.format(''), '');
|
|
assert.strictEqual(url.format({}), '');
|