@teamsight/flight
Version:
Lambda life cycles
54 lines • 2.55 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
require("should");
const flight_test_helper_1 = require("./flight-test-helper");
const types_1 = require("./types");
describe("http-handler-test-helper", () => {
it("generate event with authorizer data", () => __awaiter(this, void 0, void 0, function* () {
const auth = {
sub: "a",
service: types_1.Service.TeamSight,
orgId: "org123",
userId: "owner123",
isOwner: true
};
const event = flight_test_helper_1.FlightTestHelper.stubEvent(null, auth);
event.requestContext.authorizer.sub.match('"a"');
}));
it("generate event with object body", () => __awaiter(this, void 0, void 0, function* () {
const event = flight_test_helper_1.FlightTestHelper.stubEvent({ hello: "world" });
event.body.should.equal('{"hello":"world"}');
}));
it("generate event successfully", () => {
flight_test_helper_1.FlightTestHelper.stubEvent();
});
it("stubAuthorizerEvent", () => {
flight_test_helper_1.FlightTestHelper.stubAuthorizerEvent();
});
it("stubAuthorizerResult", () => {
flight_test_helper_1.FlightTestHelper.stubAuthorizerResult();
});
it("stubScheduledEvent", () => {
flight_test_helper_1.FlightTestHelper.stubScheduledEvent();
});
it("generate context", () => __awaiter(this, void 0, void 0, function* () {
const context = flight_test_helper_1.FlightTestHelper.stubContext();
context.getRemainingTimeInMillis().should.equal(0);
context.done();
context.fail("");
context.succeed("");
}));
it("stubSnsEvent", () => {
const event = flight_test_helper_1.FlightTestHelper.stubSnsEvent({ hello: "world" });
event.Records[0].Sns.Message.should.equal('{"hello":"world"}');
});
});
//# sourceMappingURL=flight-test-helper.test.js.map