Skip to content

Commit

Permalink
test: fix tests (CodeGenieApp#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettstack committed Oct 6, 2021
1 parent 35c686c commit da1a1b2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
eventSourceName,
path: '/users/2',
httpMethod: 'PUT',
body: global.btoa(JSON.stringify({ name })),
body: Buffer.from(JSON.stringify({ name }), 'binary').toString('base64'),
isBase64Encoded: true,
multiValueHeaders: {
'content-type': ['application/json']
Expand Down
6 changes: 2 additions & 4 deletions __tests__/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function getReqRes (multiValueHeaders = {}) {
return requestResponse
}

test('getRequestResponse: with headers', async (done) => {
test('getRequestResponse: with headers', async () => {
const { request } = await getReqRes({ 'x-foo': ['foo'] })
expect(request).toBeInstanceOf(ServerlessRequest)
expect(request.body).toBeInstanceOf(Buffer)
Expand All @@ -94,10 +94,9 @@ test('getRequestResponse: with headers', async (done) => {
'x-foo': 'foo',
'content-length': Buffer.byteLength('Hello serverless!')
})
done()
})

test('getRequestResponse: without headers', async (done) => {
test('getRequestResponse: without headers', async () => {
const requestResponse = await getReqRes()
expect(requestResponse.request).toBeInstanceOf(ServerlessRequest)
expect(requestResponse.request.body).toBeInstanceOf(Buffer)
Expand All @@ -108,7 +107,6 @@ test('getRequestResponse: without headers', async (done) => {
expect(requestResponse.request.headers).toEqual({
'content-length': Buffer.byteLength('Hello serverless!')
})
done()
})

describe('respondToEventSourceWithError', () => {
Expand Down
2 changes: 1 addition & 1 deletion jest-helpers/lambda-edge-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function makeLambdaEdgeEvent (values = {}) {
if (!mergedEvent.request.method) mergedEvent.request.method = values.httpMethod

if (!mergedEvent.request.body.data) {
mergedEvent.request.body.data = values.isBase64Encoded ? values.body : global.btoa(values.body)
mergedEvent.request.body.data = values.isBase64Encoded ? values.body : Buffer.from(values.body || '', 'binary').toString('base64')
}
// if (!mergedEvent.request.querysting) mergedEvent.request.querysting = values.httpMethod
return {
Expand Down

0 comments on commit da1a1b2

Please sign in to comment.