@rxx/worker
Version:
React MVI micro framework.
45 lines (44 loc) • 1.96 kB
JavaScript
;
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var advice_1 = require("../advice");
var combine_advice_1 = require("../combine-advice");
var intent_1 = require("../../intent/intent");
var chai_1 = require("chai");
var subject_1 = require("../../subject");
describe('combine-advice.ts', function () {
describe('combineAdvice', function () {
it('should combine all advices', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var called, result, mi, advice1, advice2, intent, tree;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
called = false;
result = [];
mi = new advice_1.MethodInvocation(function () {
called = true;
}, 1, [], '', '');
advice1 = function (mi) {
result.push('advice1');
mi.proceed();
};
advice2 = function (mi) {
result.push('advice2');
mi.proceed();
};
intent = new intent_1.Intent();
tree = new subject_1.SubjectTree();
return [4, combine_advice_1.combineAdvice(advice1, advice2)(mi, function (type, payload) {
intent.push(type, payload);
tree.notify({ type: type, payload: payload });
})];
case 1:
_a.sent();
chai_1.expect(result).to.be.deep.equal(['advice1', 'advice2']);
return [2];
}
});
}); });
});
});