Skip to content

Commit

Permalink
test: add test for resolutionMode with fresh server
Browse files Browse the repository at this point in the history
  • Loading branch information
semantic-release-bot committed Aug 17, 2018
1 parent b0927b8 commit 790e976
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const app = require('../examples/basic-starter/app')

const server = awsServerlessExpress.createServer(app)
const lambdaFunction = {
handler: (event, context, resolutionMode, callback) => awsServerlessExpress.proxy(server, event, context, resolutionMode, callback)
handler: (event, context, resolutionMode, callback, _server = server) => awsServerlessExpress.proxy(_server, event, context, resolutionMode, callback)
}

function clone (json) {
Expand Down Expand Up @@ -96,6 +96,7 @@ describe('integration tests', () => {
succeed
})
})

test('GET JSON collection', (done) => {
const succeed = response => {
delete response.headers.date
Expand Down Expand Up @@ -199,6 +200,27 @@ describe('integration tests', () => {
.promise.then(succeed)
})

test('GET JSON single (resolutionMode = PROMISE; new server)', (done) => {
const succeed = response => {
delete response.headers.date
expect(response).toEqual(makeResponse({
'body': '{"id":1,"name":"Joe"}',
'headers': {
'content-length': '21',
'etag': 'W/"15-rRboW+j/yFKqYqV6yklp53+fANQ"'
}
}))
newServer.close()
done()
}
const newServer = awsServerlessExpress.createServer(app)
lambdaFunction.handler(makeEvent({
path: '/users/1',
httpMethod: 'GET'
}), {}, 'PROMISE', null, newServer)
.promise.then(succeed)
})

test('GET JSON single 404', (done) => {
const succeed = response => {
delete response.headers.date
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"path": "@semantic-release/git",
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md",
"dist/**/*.{js|css}"
],
Expand Down

0 comments on commit 790e976

Please sign in to comment.