-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make headers an object instead of an array (#386)
* fix: make headers an object instead of an array * fix: add unit test Co-authored-by: Christian Hoffmann <352753+hffmnn@users.noreply.github.co>
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const eventSources = require('../src/event-sources') | ||
const testUtils = require('../src/event-sources/utils.test') | ||
|
||
const apiGatewayEventSource = eventSources.getEventSource({ | ||
eventSourceName: 'AWS_API_GATEWAY_V2' | ||
}) | ||
|
||
test('request has correct headers', () => { | ||
const req = getReq() | ||
// see https://github.com/vendia/serverless-express/issues/387 | ||
expect(typeof req).toEqual('object') | ||
expect(JSON.stringify(req.headers)).toEqual( | ||
'{"cookie":"","host":"localhost:9000","user-agent":"curl/7.64.1","accept":"*/*","x-forwarded-proto":"http","x-forwarded-port":"9000"}' | ||
) | ||
}) | ||
|
||
function getReq () { | ||
const event = testUtils.sam_httpapi_event | ||
const request = apiGatewayEventSource.getRequest({ event }) | ||
return request | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters