0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-url-format-invalid-input.js
Yagiz Nizipli 59220bb08a
test: move more url tests to node:test
PR-URL: https://github.com/nodejs/node/pull/54636
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2024-09-13 00:29:55 +00:00

31 lines
600 B
JavaScript

'use strict';
require('../common');
const assert = require('node:assert');
const url = require('node:url');
const { test } = require('node:test');
test('format invalid input', () => {
const throwsObjsAndReportTypes = [
undefined,
null,
true,
false,
0,
function() {},
Symbol('foo'),
];
for (const urlObject of throwsObjsAndReportTypes) {
assert.throws(() => {
url.format(urlObject);
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
});
}
assert.strictEqual(url.format(''), '');
assert.strictEqual(url.format({}), '');
});