UNPKG

@teamsight/flight

Version:

Lambda life cycles

117 lines 3.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class FlightTestHelper { static stubContext() { return { callbackWaitsForEmptyEventLoop: false, functionName: "", functionVersion: "", invokedFunctionArn: "", memoryLimitInMB: 128, awsRequestId: "", logGroupName: "", logStreamName: "", getRemainingTimeInMillis: () => 0, done: (error, result) => null, fail: (error) => null, succeed: (messageOrObject) => null }; } static stubEvent(body, authorizer) { const event = { body: body ? JSON.stringify(body) : "", headers: {}, httpMethod: "", isBase64Encoded: false, path: "", pathParameters: {}, queryStringParameters: {}, stageVariables: {}, requestContext: { accountId: "", apiId: "", authorizer: {}, httpMethod: "", identity: null, path: "", stage: "", requestId: "", requestTimeEpoch: 0, resourceId: "", resourcePath: "" }, resource: "" }; if (authorizer) { event.requestContext.authorizer = Object.keys(authorizer).reduce((auth, key) => { auth[key] = JSON.stringify(authorizer[key]); return auth; }, {}); } return event; } static stubSnsEvent(data) { const msg = { Records: [ { EventVersion: "", EventSubscriptionArn: "", EventSource: "", Sns: { SignatureVersion: "", Timestamp: "", Signature: "", SigningCertUrl: "", MessageId: "", Message: JSON.stringify(data), MessageAttributes: null, Type: "", UnsubscribeUrl: "", TopicArn: "", Subject: "" } } ] }; return msg; } static stubAuthorizerEvent() { return { type: "TOKEN", methodArn: "arn", headers: { Authorization: "Bearer 123" }, pathParameters: {} }; } static stubAuthorizerResult() { return { principalId: "principalId", policyDocument: { Version: "123", Statement: [ { Action: "", Effect: "", Resource: "" } ] } }; } static stubScheduledEvent() { return { account: "", region: "", detail: {}, "detail-type": "", source: "", time: "", id: "", resources: [] }; } } exports.FlightTestHelper = FlightTestHelper; //# sourceMappingURL=flight-test-helper.js.map