-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for options validation of createServer
PR-URL: #30541 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
- Loading branch information
1 parent
ab887bd
commit 45e5730
Showing
3 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}` | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}` | ||
} | ||
); | ||
}); |