Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions test/keepAliveTimeout.test.js → test/keep-alive-timeout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@

const Fastify = require('..')
const http = require('node:http')
const t = require('tap')
const test = t.test
const { test } = require('node:test')

test('keepAliveTimeout', t => {
t.plan(6)

try {
Fastify({ keepAliveTimeout: 1.3 })
t.fail('option must be an integer')
t.assert.fail('option must be an integer')
} catch (err) {
t.ok(err)
t.assert.ok(err)
}

try {
Fastify({ keepAliveTimeout: [] })
t.fail('option must be an integer')
t.assert.fail('option must be an integer')
} catch (err) {
t.ok(err)
t.assert.ok(err)
}

const httpServer = Fastify({ keepAliveTimeout: 1 }).server
t.equal(httpServer.keepAliveTimeout, 1)
t.assert.strictEqual(httpServer.keepAliveTimeout, 1)

const httpsServer = Fastify({ keepAliveTimeout: 2, https: {} }).server
t.equal(httpsServer.keepAliveTimeout, 2)
t.assert.strictEqual(httpsServer.keepAliveTimeout, 2)

const http2Server = Fastify({ keepAliveTimeout: 3, http2: true }).server
t.not(http2Server.keepAliveTimeout, 3)
t.assert.notStrictEqual(http2Server.keepAliveTimeout, 3)

const serverFactory = (handler, _) => {
const server = http.createServer((req, res) => {
Expand All @@ -39,5 +38,5 @@ test('keepAliveTimeout', t => {
return server
}
const customServer = Fastify({ keepAliveTimeout: 4, serverFactory }).server
t.equal(customServer.keepAliveTimeout, 5)
t.assert.strictEqual(customServer.keepAliveTimeout, 5)
})