xmt-base
Version:
Backend Server Framework of XmT Inc.
36 lines • 1.26 kB
JavaScript
;
const chai_1 = require("chai");
const interface_1 = require("../lib/interface");
describe("schedule()", function () {
it("should call the task functions one by one", function (done) {
let array = [];
function task1(request, response, next) {
array.push(1);
return next();
}
function task2(request, response, next) {
array.push(2);
return next();
}
function task3(request, response) {
array.push(3);
chai_1.expect(array).to.deep.equal([1, 2, 3]);
done();
}
interface_1.schedule([task1, task2, task3], {}, {});
});
it("Should catch unhandled error that happened in app logic", function (done) {
function task(request, response, next) {
throw "Only for test: this is an unhandled error!";
}
let mockResponseObject = {
statusCode: undefined,
end: function () {
chai_1.expect(mockResponseObject.statusCode).to.equal(500);
done();
}
};
interface_1.schedule([task], {}, mockResponseObject);
});
});
//# sourceMappingURL=schedule.js.map