-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsimple.spec.js
40 lines (35 loc) · 1.3 KB
/
simple.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { Rools } = require('..');
const { frank, michael } = require('./facts/users')();
const { good, bad } = require('./facts/weather')();
const {
ruleMoodGreat, ruleMoodSad, ruleGoWalking, ruleStayAtHome,
} = require('./rules/mood');
require('./setup');
describe('Rools.evaluate() / simple', () => {
let rools;
before(async () => {
rools = new Rools();
await rools.register([ruleMoodGreat, ruleMoodSad, ruleGoWalking, ruleStayAtHome]);
});
it('should evaluate scenario 1', async () => {
const facts = { user: frank, weather: good };
await rools.evaluate(facts);
expect(facts.user.mood).to.be.equal('great');
expect(facts.goWalking).to.be.equal(true);
expect(facts.stayAtHome).to.be.equal(undefined);
});
it('should evaluate scenario 2', async () => {
const facts = { user: michael, weather: good };
await rools.evaluate(facts);
expect(facts.user.mood).to.be.equal('sad');
expect(facts.goWalking).to.be.equal(undefined);
expect(facts.stayAtHome).to.be.equal(true);
});
it('should evaluate scenario 3', async () => {
const facts = { user: frank, weather: bad };
await rools.evaluate(facts);
expect(facts.user.mood).to.be.equal('great');
expect(facts.goWalking).to.be.equal(undefined);
expect(facts.stayAtHome).to.be.equal(true);
});
});