You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
631 B

'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({}), '');