0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-url-format-invalid-input.js
Eduardo Leggiero 8520e6f280 lib: fix urlObject parameter name in url.format
Documentation, error message, and code now use the same argument name.

PR-URL: https://github.com/nodejs/node/pull/14031
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-07-05 09:58:47 -07:00

27 lines
749 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) {
const error = common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "urlObject" argument must be one of type object or string. ' +
`Received type ${type}`
});
assert.throws(function() { url.format(urlObject); }, error);
}
assert.strictEqual(url.format(''), '');
assert.strictEqual(url.format({}), '');