diff --git a/test/parallel/test-http2-createsecureserver-nooptions.js b/test/parallel/test-http2-createsecureserver-nooptions.js deleted file mode 100644 index 22a7562388c75a..00000000000000 --- a/test/parallel/test-http2-createsecureserver-nooptions.js +++ /dev/null @@ -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}` - } - ); -}); diff --git a/test/parallel/test-http2-createsecureserver-options.js b/test/parallel/test-http2-createsecureserver-options.js new file mode 100644 index 00000000000000..4ef85a45b5b84b --- /dev/null +++ b/test/parallel/test-http2-createsecureserver-options.js @@ -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}` + } + ); +}); diff --git a/test/parallel/test-http2-createserver-options.js b/test/parallel/test-http2-createserver-options.js new file mode 100644 index 00000000000000..d322506f55e3e0 --- /dev/null +++ b/test/parallel/test-http2-createserver-options.js @@ -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}` + } + ); +});