summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-util-assert-valid-pseudoheader.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-08-30 15:52:26 -0700
committerJames M Snell <jasnell@gmail.com>2017-09-05 12:25:33 -0700
commit2f9d9e5fe3b09d3fe54bbf04a61b1fe8289414c0 (patch)
treec327878d4660861aae005365ee3a82338ce0c00a /test/parallel/test-http2-util-assert-valid-pseudoheader.js
parent425ce5203678dd4e3484d6fd49740212ec4268cc (diff)
downloadandroid-node-v8-2f9d9e5fe3b09d3fe54bbf04a61b1fe8289414c0.tar.gz
android-node-v8-2f9d9e5fe3b09d3fe54bbf04a61b1fe8289414c0.tar.bz2
android-node-v8-2f9d9e5fe3b09d3fe54bbf04a61b1fe8289414c0.zip
test: http2 test coverage for assertValidPseudoHeader
PR-URL: https://github.com/nodejs/node/pull/15105 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-util-assert-valid-pseudoheader.js')
-rw-r--r--test/parallel/test-http2-util-assert-valid-pseudoheader.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/parallel/test-http2-util-assert-valid-pseudoheader.js b/test/parallel/test-http2-util-assert-valid-pseudoheader.js
new file mode 100644
index 0000000000..27050fedd6
--- /dev/null
+++ b/test/parallel/test-http2-util-assert-valid-pseudoheader.js
@@ -0,0 +1,31 @@
+// Flags: --expose-internals
+'use strict';
+
+const common = require('../common');
+
+// Tests the assertValidPseudoHeader function that is used within the
+// mapToHeaders function. The assert function is not exported so we
+// have to test it through mapToHeaders
+
+const { mapToHeaders } = require('internal/http2/util');
+const assert = require('assert');
+
+function isNotError(val) {
+ assert(!(val instanceof Error));
+}
+
+function isError(val) {
+ common.expectsError({
+ code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
+ type: Error,
+ message: '":foo" is an invalid pseudoheader or is used incorrectly'
+ })(val);
+}
+
+isNotError(mapToHeaders({ ':status': 'a' }));
+isNotError(mapToHeaders({ ':path': 'a' }));
+isNotError(mapToHeaders({ ':authority': 'a' }));
+isNotError(mapToHeaders({ ':scheme': 'a' }));
+isNotError(mapToHeaders({ ':method': 'a' }));
+
+isError(mapToHeaders({ ':foo': 'a' }));