summaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorZYSzys <zyszys98@gmail.com>2019-11-19 15:38:25 +0800
committerZYSzys <zyszys98@gmail.com>2019-11-21 17:30:13 +0800
commit52e1bbde01e1f35b13a9a14a2d428fd318c7ef4a (patch)
treece36d7760f61e90e08b3e32c339b07ec51fa0518 /test/parallel
parent8138e9ce508df75a9bef66dcbb7389bfceb71c23 (diff)
downloadnode-new-52e1bbde01e1f35b13a9a14a2d428fd318c7ef4a.tar.gz
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>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-http2-createsecureserver-nooptions.js22
-rw-r--r--test/parallel/test-http2-createsecureserver-options.js35
-rw-r--r--test/parallel/test-http2-createserver-options.js35
3 files changed, 70 insertions, 22 deletions
diff --git a/test/parallel/test-http2-createsecureserver-nooptions.js b/test/parallel/test-http2-createsecureserver-nooptions.js
deleted file mode 100644
index 22a7562388..0000000000
--- 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 0000000000..4ef85a45b5
--- /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 0000000000..d322506f55
--- /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}`
+ }
+ );
+});