From 365424edcf53762fc91c399d5904289868a2d3c2 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 28 Feb 2019 17:06:38 +0100 Subject: [PATCH] Added test --- test/cookie.test.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/cookie.test.js b/test/cookie.test.js index b6091f8..2eaeace 100644 --- a/test/cookie.test.js +++ b/test/cookie.test.js @@ -123,10 +123,20 @@ test('cookies get set correctly with millisecond dates', (t) => { }) test('parses incoming cookies', (t) => { - t.plan(6) + t.plan(6 + 3 * 3) const fastify = Fastify() fastify.register(plugin) + // check that it parses the cookies in the onRequest hook + for (let hook of ['preParsing', 'preValidation', 'preHandler']) { + fastify.addHook(hook, (req, reply, done) => { + t.ok(req.cookies) + t.ok(req.cookies.bar) + t.is(req.cookies.bar, 'bar') + done() + }) + } + fastify.get('/test2', (req, reply) => { t.ok(req.cookies) t.ok(req.cookies.bar)