Skip to content

Commit

Permalink
Automation tests
Browse files Browse the repository at this point in the history
Co-authored-by: Denis Alustau <[email protected]>
  • Loading branch information
deleugpn and alustau committed Jul 5, 2023
1 parent 968f9dc commit a38246c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ app.use(bodyParser.raw({
type: '*/*'
}));


app.all('*', async (req: Request, res: Response, next) => {
const event = httpRequestToEvent(req);

Expand Down
20 changes: 20 additions & 0 deletions test/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ describe('server', () => {
});
});

it('handles cookies', async () => {
const response = await request(app)
.get('/')
.set('Cookie', ['cookie1=a', 'cookie2=b']);

const lambdaPayload = getEventFromLambdaApiCall(lambda, 0);

expect(lambdaPayload.cookies).toEqual(['cookie1=a', 'cookie2=b']);
});

it('handles cookies with `;` on it', async () => {
const response = await request(app)
.get('/')
.set('Cookie', ['cookie1=a;b', 'cookie2=c;d']);

const lambdaPayload = getEventFromLambdaApiCall(lambda, 0);

expect(lambdaPayload.cookies).toEqual(['cookie1=a;b', 'cookie2=c;d']);
});

it('sets cookies', async () => {
const response = await request(app).post('/');
expect(response.header['set-cookie']).toEqual(['cookie1=a', 'cookie2=b']);
Expand Down

0 comments on commit a38246c

Please sign in to comment.