mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8c4b8b201a
Refs: https://github.com/nodejs/node/pull/41660 PR-URL: https://github.com/nodejs/node/pull/41678 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
40 lines
876 B
JavaScript
40 lines
876 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const http2 = require('http2');
|
|
|
|
// Verify that setTimeout callback verifications work correctly
|
|
const verifyCallbacks = (server) => {
|
|
const testTimeout = 10;
|
|
|
|
[true, 1, {}, [], null, 'test'].forEach((notFunction) => {
|
|
assert.throws(
|
|
() => server.setTimeout(testTimeout, notFunction),
|
|
{
|
|
name: 'TypeError',
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
}
|
|
);
|
|
});
|
|
|
|
// No callback
|
|
const returnedVal = server.setTimeout(testTimeout);
|
|
assert.strictEqual(returnedVal.timeout, testTimeout);
|
|
};
|
|
|
|
// Test with server
|
|
{
|
|
const server = http2.createServer();
|
|
verifyCallbacks(server);
|
|
}
|
|
|
|
// Test with secure server
|
|
{
|
|
const secureServer = http2.createSecureServer({});
|
|
verifyCallbacks(secureServer);
|
|
}
|