Skip to content

Commit

Permalink
✍️ added lambdaRequest method test #7
Browse files Browse the repository at this point in the history
  • Loading branch information
8eecf0d2 committed Oct 16, 2018
1 parent abcb8f8 commit 5f65fa3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/ts/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,29 @@ mocha.describe('Server', () => {

server.close();
});

mocha.it('should correctly format lambda request', async () => {
const requestObj = {
path: "/foo",
method: "GET",
url: "/foo?bar[0]=baz&bar[1]=qak",
headers: {
"content-type": "application/json"
},
body: { test: true },
}

//@ts-ignore
const lambdaRequest = Server.lambdaRequest(requestObj);

assert.equal(lambdaRequest.path, "/foo");
assert.equal(lambdaRequest.httpMethod, "GET");
assert.equal(lambdaRequest.queryStringParameters["bar[0]"], "baz");
assert.equal(lambdaRequest.queryStringParameters["bar[1]"], "qak");
assert.equal(lambdaRequest.headers["content-type"], "application/json");
assert.equal(JSON.stringify(lambdaRequest.body), JSON.stringify({ test: true }));
assert.equal(lambdaRequest.isBase64Encoded, false);
});

});
});

0 comments on commit 5f65fa3

Please sign in to comment.