mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
78182458e6
PR-URL: https://github.com/nodejs/node/pull/11162 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
23 lines
631 B
JavaScript
23 lines
631 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({}), '');
|