2017-01-28 17:23:47 +08:00
|
|
|
'use strict';
|
2017-06-29 00:12:12 +08:00
|
|
|
const common = require('../common');
|
2017-01-28 17:23:47 +08:00
|
|
|
const assert = require('assert');
|
|
|
|
const url = require('url');
|
|
|
|
|
2019-09-23 08:17:25 +02:00
|
|
|
const throwsObjsAndReportTypes = [
|
|
|
|
undefined,
|
|
|
|
null,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
function() {},
|
2021-03-26 08:51:08 -07:00
|
|
|
Symbol('foo'),
|
2019-09-23 08:17:25 +02:00
|
|
|
];
|
2017-02-04 21:39:20 +08:00
|
|
|
|
2019-09-23 08:17:25 +02:00
|
|
|
for (const urlObject of throwsObjsAndReportTypes) {
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2018-01-05 13:13:51 +05:30
|
|
|
url.format(urlObject);
|
|
|
|
}, {
|
2017-06-29 00:12:12 +08:00
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'TypeError',
|
2019-09-23 08:17:25 +02:00
|
|
|
message: 'The "urlObject" argument must be one of type object or string.' +
|
|
|
|
common.invalidArgTypeHelper(urlObject)
|
2017-06-29 00:12:12 +08:00
|
|
|
});
|
2017-01-28 17:23:47 +08:00
|
|
|
}
|
|
|
|
assert.strictEqual(url.format(''), '');
|
|
|
|
assert.strictEqual(url.format({}), '');
|