Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Jul 25, 2024
1 parent 2a0ffbe commit 230d812
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/session.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Fastify = require('fastify')
const fastifyCookie = require('@fastify/cookie')
const fastifySession = require('..')
const { buildFastify, DEFAULT_OPTIONS, DEFAULT_COOKIE, DEFAULT_SESSION_ID, DEFAULT_SECRET, DEFAULT_COOKIE_VALUE } = require('./util')
const { setTimeout: sleep } = require('timers/promises')

test('should add session object to request', async (t) => {
t.plan(2)
Expand Down Expand Up @@ -413,9 +414,9 @@ test('should not reset session cookie expiration if rolling is false', async (t)
}
fastify.register(fastifyCookie)
fastify.register(fastifySession, options)
fastify.addHook('onRequest', (request, reply, done) => {
fastify.addHook('onRequest', async (request, reply) => {
await sleep(1)
reply.send(request.session.expires)
done()
})

fastify.get('/', (request, reply) => reply.send(200))
Expand Down Expand Up @@ -449,10 +450,10 @@ test('should update the expires property of the session using Session#touch() ev
}
fastify.register(fastifyCookie)
fastify.register(fastifySession, options)
fastify.addHook('onRequest', (request, reply, done) => {
fastify.addHook('onRequest', async (request, reply) => {
await sleep(1)
request.session.touch()
reply.send(request.session.cookie.expires)
done()
})

fastify.get('/', (request, reply) => reply.send(200))
Expand Down

0 comments on commit 230d812

Please sign in to comment.