jslambda-handler
Advanced tools
Comparing version
{ | ||
"name": "jslambda-handler", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"main": "src/index.js", | ||
@@ -14,2 +14,3 @@ "repository": "https://github.com/tgorka/jslambda-handler.git", | ||
"clean": "yarn clean:dist && yarn clean:types", | ||
"deploy": "yarn build && yarn publish", | ||
"publish": "yarn login && yarn publish", | ||
@@ -16,0 +17,0 @@ "test": "env-cmd ./environment/ci.env jest --verbose --runInBand" |
@@ -13,2 +13,4 @@ "use strict"; | ||
`obligatoryArgs ${obligatoryArgsJsonPath}, optionalArgs ${optionalArgsJsonPath}`); | ||
// empty event is {} | ||
event = event || {}; | ||
// Check if event.Records[0].Sns.Message exist | ||
@@ -15,0 +17,0 @@ let snsEvent = (((event.Records && event.Records[0]) || {}).Sns || {}).Message; |
@@ -21,5 +21,5 @@ "use strict"; | ||
}; | ||
const caller = (fun, args) => new Promise((resolve, reject) => { | ||
const caller = (fun, args, event = SRC_EVENT) => new Promise((resolve, reject) => { | ||
const lambdaFun = _1.default(fun, args); | ||
lambdaFun(SRC_EVENT, SRC_CONTEXT, (err, data) => { | ||
lambdaFun(event, SRC_CONTEXT, (err, data) => { | ||
if (!!err) | ||
@@ -31,2 +31,13 @@ reject(err); | ||
}); | ||
describe("handler:noEvent Test", () => { | ||
let data = undefined; | ||
beforeAll(async () => { | ||
data = await caller(() => 1, undefined, null); | ||
}); | ||
afterAll(async () => { | ||
// NONE | ||
}); | ||
it("handler result should not be null", () => expect(data).not.toBeNull()); | ||
it("handler result should be equal", () => expect(data).toBe(1)); | ||
}); | ||
describe("handler:noReturn Test", () => { | ||
@@ -33,0 +44,0 @@ let data = undefined; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16818
6.52%208
6.67%