node/test/parallel/test-https-argument-of-creating.js
Ruben Bridgewater b08a867d60
benchmark,doc,lib: capitalize more comments
PR-URL: https://github.com/nodejs/node/pull/26849
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-03-27 17:20:06 +01:00

46 lines
1.3 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const https = require('https');
const tls = require('tls');
const dftProtocol = {};
// Test for immutable `opts`
{
const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] };
const server = https.createServer(opts);
tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] });
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
}
// Validate that `createServer` can work with the only argument requestListener
{
const mustNotCall = common.mustNotCall();
const server = https.createServer(mustNotCall);
tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
assert.strictEqual(server.listeners('request').length, 1);
assert.strictEqual(server.listeners('request')[0], mustNotCall);
}
// Validate that `createServer` can work with no arguments
{
const server = https.createServer();
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
assert.strictEqual(server.listeners('request').length, 0);
}