Skip to content

Commit

Permalink
refactor: remove context.done and replace with object return
Browse files Browse the repository at this point in the history
Continues work started in probot#18
  • Loading branch information
Matthew Cantelon committed Nov 5, 2020
1 parent 796e0a1 commit f469c60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ module.exports.serverless = appFn => {

// Bail for null body
if (!event.body) {
return context.done(null, {
return {
statusCode: 400,
body: 'Event body is null.'
})
}
}

// Do the thing
Expand Down
6 changes: 2 additions & 4 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ describe('serverless-lambda', () => {
}
}

await handler(event, context)
expect(context.done).toHaveBeenCalledWith(null, expect.objectContaining({
statusCode: 400
}))
const result = await handler(event, context)
expect(result.statusCode).toBe(400)
expect(spy).not.toHaveBeenCalled()
})

Expand Down

0 comments on commit f469c60

Please sign in to comment.