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/12992 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Luca Maraschi <luca.maraschi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
23 lines
604 B
JavaScript
23 lines
604 B
JavaScript
'use strict';
|
|
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 = new RegExp(
|
|
`^TypeError: Parameter "urlObj" must be an object, not ${type}$`);
|
|
assert.throws(function() { url.format(obj); }, error);
|
|
}
|
|
assert.strictEqual(url.format(''), '');
|
|
assert.strictEqual(url.format({}), '');
|