@studyportals/sp-r2d2
Version:
A framework that contains various components used when developing projects that will be deployed via AWS λ.
114 lines • 5.59 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const mocha_1 = require("@testdeck/mocha");
const Moq = require("typemoq");
const application_1 = require("../../../application");
const base_response_sender_class_1 = require("../../../environment/core/response-sending/base-response-sender.class");
let BaseResponseSenderTest = class BaseResponseSenderTest {
get callbackMock() {
return this._callbackMock;
}
get callback() {
return this.callbackMock.object;
}
get testInstanceMock() {
return this._testInstanceMock;
}
get testInstance() {
return this.testInstanceMock.object;
}
before() {
this._callbackMock = Moq.Mock.ofType();
this._testInstanceMock = Moq.Mock.ofType(base_response_sender_class_1.BaseResponseSender);
this.testInstanceMock.callBase = true;
this.testInstanceMock.setup((_) => _['lambdaCallback']).returns(() => this.callback);
}
sendPong__PongDataPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
yield this.testInstance.sendPong('');
this.callbackMock.verify((_) => _(null, Moq.It.isObjectWith({ ___PONG___: 1 })), Moq.Times.once());
});
}
sendUncaughtError__ErrorPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
const error = new Error();
yield this.testInstance.sendUncaughtError(error);
this.callbackMock.verify((_) => _(error), Moq.Times.once());
});
}
sendRequestAuthorizationError__ErrorPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
const error = new application_1.AuthorizationError();
yield this.testInstance.sendRequestAuthorizationError(error);
this.callbackMock.verify((_) => _(error), Moq.Times.once());
});
}
sendEventIgnored__ResultPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
const event = {};
yield this.testInstance.sendEventIgnored(event);
this.callbackMock.verify((_) => _(null), Moq.Times.once());
});
}
sendRequestValidationError__ErrorPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
const error = new application_1.ValidationError();
yield this.testInstance.sendRequestValidationError(error);
this.callbackMock.verify((_) => _(error), Moq.Times.once());
});
}
sendRequestExecutionError__ErrorPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
const error = new application_1.ExecutionError();
yield this.testInstance.sendRequestExecutionError(error);
this.callbackMock.verify((_) => _(error), Moq.Times.once());
});
}
sendExecutionOutcome__ResultPassedToCallback() {
return __awaiter(this, void 0, void 0, function* () {
const result = 'SomeResult';
yield this.testInstance.sendExecutionOutcome(result);
this.callbackMock.verify((_) => _(null, result), Moq.Times.once());
});
}
};
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendPong__PongDataPassedToCallback", null);
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendUncaughtError__ErrorPassedToCallback", null);
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendRequestAuthorizationError__ErrorPassedToCallback", null);
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendEventIgnored__ResultPassedToCallback", null);
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendRequestValidationError__ErrorPassedToCallback", null);
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendRequestExecutionError__ErrorPassedToCallback", null);
__decorate([
mocha_1.test
], BaseResponseSenderTest.prototype, "sendExecutionOutcome__ResultPassedToCallback", null);
BaseResponseSenderTest = __decorate([
(0, mocha_1.suite)()
], BaseResponseSenderTest);
//# sourceMappingURL=base-response-sender.test.js.map