diff --git a/src/condition.js b/src/condition.js index ff6b89f..3910ffd 100644 --- a/src/condition.js +++ b/src/condition.js @@ -49,6 +49,12 @@ export default class Condition { props.operator = this.operator props.value = this.value props.fact = this.fact + if (this.factResult !== undefined) { + props.factResult = this.factResult + } + if (this.result !== undefined) { + props.result = this.result + } if (this.params) { props.params = this.params } diff --git a/test/engine-event.test.js b/test/engine-event.test.js index efaf649..bf27f85 100644 --- a/test/engine-event.test.js +++ b/test/engine-event.test.js @@ -305,7 +305,7 @@ describe('Engine: event', () => { rule.on('success', successSpy) await engine.run() let ruleResult = successSpy.getCall(0).args[2] - let expected = '{"conditions":{"priority":1,"any":[{"operator":"greaterThanInclusive","value":21,"fact":"age"},{"operator":"equal","value":true,"fact":"qualified"}]},"event":{"type":"setDrinkingFlag","params":{"canOrderDrinks":true}},"priority":100,"result":true}' + let expected = '{"conditions":{"priority":1,"any":[{"operator":"greaterThanInclusive","value":21,"fact":"age","factResult":21,"result":true},{"operator":"equal","value":true,"fact":"qualified","factResult":false,"result":false}]},"event":{"type":"setDrinkingFlag","params":{"canOrderDrinks":true}},"priority":100,"result":true}' expect(JSON.stringify(ruleResult)).to.equal(expected) }) })