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/17997 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
28 lines
717 B
JavaScript
28 lines
717 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 [urlObject, type] of throwsObjsAndReportTypes) {
|
|
common.expectsError(function() {
|
|
url.format(urlObject);
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "urlObject" argument must be one of type Object or string. ' +
|
|
`Received type ${type}`
|
|
});
|
|
}
|
|
assert.strictEqual(url.format(''), '');
|
|
assert.strictEqual(url.format({}), '');
|