From e6fd5fb41b0c378f1e997a15c2f9a1be85a19c97 Mon Sep 17 00:00:00 2001 From: William Date: Thu, 24 Oct 2024 19:54:54 -0500 Subject: [PATCH] Adding test for cookies --- tests/server.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/server.test.js b/tests/server.test.js index 9f100a1..5d93975 100644 --- a/tests/server.test.js +++ b/tests/server.test.js @@ -72,3 +72,27 @@ test('no headers sent', async () => { await expect(response.body).toEqual('SGVsbG8gV29ybGQh'); }); + +test('cookie headers', async () => { + const app = express(); + const cookieEvent = { ...event }; + + app.get('/', (req, res) => { + res.setHeader('set-cookie', ['foo=bar', 'test=true']); + res.send('Hello World!'); + }); + + const response = await lambdaServer(app, true)(cookieEvent); + + await expect(response.body).toEqual('SGVsbG8gV29ybGQh'); + await expect(response.headers).toEqual({ + 'Set-cookie': 'foo=bar', + 'sEt-cookie': 'test=true', + 'content-length': '12', + 'content-type': 'text/html; charset=utf-8', + date: expect.any(String), + etag: 'W/"c-Lve95gjOVATpfV8EL5X4nxwjKHE"', + 'keep-alive': 'timeout=5', + 'x-powered-by': 'Express', + }); +});