Skip to content

Commit

Permalink
Using facts in condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed Jan 7, 2016
1 parent 151834e commit 3ede884
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/engine.js
Expand Up @@ -51,6 +51,22 @@ exports['add and run rule on model and facts'] = function (test) {
test.equal(facts.hasFever, true);
}

exports['add and run rule using facts in condition'] = function (test) {
var model = { age: 80 };
var facts = { hasFever: true };

var eng = engine({});

eng.rule({ name: 'rule1', title: 'Rule 1' })
.when("model.age > 70")
.when("facts.hasFever")
.then("facts.critical = true");

eng.run(model, facts);

test.equal(facts.critical, true);
}

exports['two rules and run on model'] = function (test) {
var model = { temperature: 40 };

Expand Down

0 comments on commit 3ede884

Please sign in to comment.