Skip to content

Commit

Permalink
✍️ added lambdaContext method test #7
Browse files Browse the repository at this point in the history
  • Loading branch information
8eecf0d2 committed Oct 17, 2018
1 parent 5f65fa3 commit 17ac6c8
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 @@ -113,5 +113,29 @@ mocha.describe('Server', () => {
assert.equal(lambdaRequest.isBase64Encoded, false);
});

mocha.it('should correctly format lambda context', async () => {
const requestWithoutBearer = {
headers: {}
}

//@ts-ignore
const lambdaContextWithoutBearer = Server.lambdaContext(requestWithoutBearer);

assert.equal(JSON.stringify(lambdaContextWithoutBearer), JSON.stringify({}));

const requestWithBearer = {
headers: {
"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ._NaFhGu8tCCgBKksGBA6ADwRdKx3e9GES_KyF4A5phE"
}
}

//@ts-ignore
const lambdaContextWithBearer = Server.lambdaContext(requestWithBearer);

assert.equal(lambdaContextWithBearer.identity.url, "");
assert.equal(lambdaContextWithBearer.identity.token, "");
assert.equal(JSON.stringify(lambdaContextWithBearer.user), JSON.stringify({ foo: "bar" }));
});

});
});

0 comments on commit 17ac6c8

Please sign in to comment.