mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: add test for options validation of createServer
PR-URL: https://github.com/nodejs/node/pull/30541 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
1 parent
e10f9224ac
commit
6da56e91a3
3 files changed
+70
-22
No files matched your search
@@ -1,22 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
|
||||
// Error if options are not passed to createSecureServer
|
||||
const invalidOptions = [() => {}, 1, 'test', null];
|
||||
invalidOptions.forEach((invalidOption) => {
|
||||
assert.throws(
|
||||
() => http2.createSecureServer(invalidOption),
|
||||
{
|
||||
name: 'TypeError',
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "options" argument must be of type Object. Received ' +
|
||||
`type ${typeof invalidOption}`
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
|
||||
// Error if invalid options are passed to createSecureServer
|
||||
const invalidOptions = [() => {}, 1, 'test', null, Symbol('test')];
|
||||
invalidOptions.forEach((invalidOption) => {
|
||||
assert.throws(
|
||||
() => http2.createSecureServer(invalidOption),
|
||||
{
|
||||
name: 'TypeError',
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "options" argument must be of type Object. Received ' +
|
||||
`type ${typeof invalidOption}`
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Error if invalid options.settings are passed to createSecureServer
|
||||
invalidOptions.forEach((invalidSettingsOption) => {
|
||||
assert.throws(
|
||||
() => http2.createSecureServer({ settings: invalidSettingsOption }),
|
||||
{
|
||||
name: 'TypeError',
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "options.settings" property must be of type Object. ' +
|
||||
`Received type ${typeof invalidSettingsOption}`
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
|
||||
// Error if invalid options are passed to createServer
|
||||
const invalidOptions = [1, true, 'test', null, Symbol('test')];
|
||||
invalidOptions.forEach((invalidOption) => {
|
||||
assert.throws(
|
||||
() => http2.createServer(invalidOption),
|
||||
{
|
||||
name: 'TypeError',
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "options" argument must be of type Object. Received ' +
|
||||
`type ${typeof invalidOption}`
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Error if invalid options.settings are passed to createServer
|
||||
invalidOptions.forEach((invalidSettingsOption) => {
|
||||
assert.throws(
|
||||
() => http2.createServer({ settings: invalidSettingsOption }),
|
||||
{
|
||||
name: 'TypeError',
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "options.settings" property must be of type Object. ' +
|
||||
`Received type ${typeof invalidSettingsOption}`
|
||||
}
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user