0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-http2-client-promisify-connect-error.js
ehsankhfr 42bce05ef6
http2: reject failed http2.connect when used with promisify
PR-URL: https://github.com/nodejs/node/pull/53475
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-06-20 14:48:27 +02:00

25 lines
657 B
JavaScript

'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.listen(0, common.mustCall(() => {
const port = server.address().port;
server.close(() => {
const connect = util.promisify(http2.connect);
connect(`http://localhost:${port}`)
.then(common.mustNotCall('Promise should not be resolved'))
.catch(common.mustCall((err) => {
assert(err instanceof Error);
assert.strictEqual(err.code, 'ECONNREFUSED');
}));
});
}));