summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-client-promisify-connect.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-09-01 14:47:31 -0700
committerJames M Snell <jasnell@gmail.com>2017-09-13 10:36:36 -0700
commit9d9552f7ee30460cdde8d9cc0b465edf1c48925d (patch)
treea730ac22dee0daa764ca8e37642ab521ae028792 /test/parallel/test-http2-client-promisify-connect.js
parentad3d899ae0d29c219e9c246414d70ddfd4a7ec3b (diff)
downloadnode-new-9d9552f7ee30460cdde8d9cc0b465edf1c48925d.tar.gz
http2: custom promisify for http2.connect
... and some other cleanups PR-URL: https://github.com/nodejs/node/pull/15207 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-client-promisify-connect.js')
-rw-r--r--test/parallel/test-http2-client-promisify-connect.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/parallel/test-http2-client-promisify-connect.js b/test/parallel/test-http2-client-promisify-connect.js
new file mode 100644
index 0000000000..5b6dccad6a
--- /dev/null
+++ b/test/parallel/test-http2-client-promisify-connect.js
@@ -0,0 +1,34 @@
+// Flags: --expose-http2
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const assert = require('assert');
+const http2 = require('http2');
+const util = require('util');
+
+const server = http2.createServer();
+server.on('stream', common.mustCall((stream) => {
+ stream.respond();
+ stream.end('ok');
+}));
+server.listen(0, common.mustCall(() => {
+
+ const connect = util.promisify(http2.connect);
+
+ connect(`http://localhost:${server.address().port}`)
+ .catch(common.mustNotCall())
+ .then(common.mustCall((client) => {
+ assert(client);
+ const req = client.request();
+ let data = '';
+ req.setEncoding('utf8');
+ req.on('data', (chunk) => data += chunk);
+ req.on('end', common.mustCall(() => {
+ assert.strictEqual(data, 'ok');
+ client.destroy();
+ server.close();
+ }));
+ }));
+}));