strong-tie/inbound-calls
0
1'use strict'2 3const Fastify = require('..')4const http = require('node:http')5const { test } = require('node:test')6 7test('connectionTimeout', async t => {8 t.plan(6)9 10 try {11 Fastify({ connectionTimeout: 1.3 })12 t.assert.fail('option must be an integer')13 } catch (err) {14 t.assert.ok(err)15 }16 17 try {18 Fastify({ connectionTimeout: [] })19 t.assert.fail('option must be an integer')20 } catch (err) {21 t.assert.ok(err)22 }23 24 const httpServer = Fastify({ connectionTimeout: 1 }).server25 t.assert.strictEqual(httpServer.timeout, 1)26 27 const httpsServer = Fastify({ connectionTimeout: 2, https: {} }).server28 t.assert.strictEqual(httpsServer.timeout, 2)29 30 const http2Server = Fastify({ connectionTimeout: 3, http2: true }).server31 t.assert.strictEqual(http2Server.timeout, 3)32 33 const serverFactory = (handler, _) => {34 const server = http.createServer((req, res) => {35 handler(req, res)36 })37 server.setTimeout(5)38 return server39 }40 const customServer = Fastify({ connectionTimeout: 4, serverFactory }).server41 t.assert.strictEqual(customServer.timeout, 5)42})43 