diff options
author | Trivikram Kamat <trivikr.dev@gmail.com> | 2017-10-08 06:23:47 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2017-10-24 00:57:32 +0300 |
commit | 6d1602244ab91e3cb3764397f973063438c726d1 (patch) | |
tree | c6b42442bde0e33bf02369e46189a31326242f92 /test | |
parent | c07d75750865e7a0ce6c812c381df8fd4d3821cb (diff) |
test: http2 add timeout no callback test case
Refs: https://github.com/nodejs/node/issues/14985
PR-URL: https://github.com/nodejs/node/pull/16082
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-http2-server-settimeout-no-callback.js | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/test/parallel/test-http2-server-settimeout-no-callback.js b/test/parallel/test-http2-server-settimeout-no-callback.js index f9d7bdfa97e..1b093c02002 100644 --- a/test/parallel/test-http2-server-settimeout-no-callback.js +++ b/test/parallel/test-http2-server-settimeout-no-callback.js @@ -5,38 +5,39 @@ 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; + const notFunctions = [true, 1, {}, [], null, 'test']; + const invalidCallBackError = { + type: TypeError, + code: 'ERR_INVALID_CALLBACK', + message: 'callback must be a function' + }; + notFunctions.forEach((notFunction) => + common.expectsError( + () => server.setTimeout(testTimeout, notFunction), + invalidCallBackError + ) + ); + + // No callback + const returnedVal = server.setTimeout(testTimeout); + assert.strictEqual(returnedVal.timeout, testTimeout); +}; + +// Test with server { const server = http2.createServer(); - common.expectsError( - () => server.setTimeout(10, 'test'), - { - code: 'ERR_INVALID_CALLBACK', - type: TypeError - }); - common.expectsError( - () => server.setTimeout(10, 1), - { - code: 'ERR_INVALID_CALLBACK', - type: TypeError - }); + verifyCallbacks(server); } +// Test with secure server { - const server = http2.createSecureServer({}); - common.expectsError( - () => server.setTimeout(10, 'test'), - { - code: 'ERR_INVALID_CALLBACK', - type: TypeError - }); - common.expectsError( - () => server.setTimeout(10, 1), - { - code: 'ERR_INVALID_CALLBACK', - type: TypeError - }); + const secureServer = http2.createSecureServer({}); + verifyCallbacks(secureServer); } |