-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdeep.spec.js
30 lines (26 loc) · 1008 Bytes
/
deep.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
const { Rools } = require('../src');
const { frank, michael } = require('./facts/users')();
const { good, bad } = require('./facts/weather')();
const {
ruleTeamMoodGreat, ruleTeamGoWalking, ruleTeamStayAtHome,
} = require('./rules/deep');
require('./setup');
describe('Rools.evaluate() / deep facts + array', () => {
let rools;
before(async () => {
rools = new Rools();
await rools.register([ruleTeamMoodGreat, ruleTeamGoWalking, ruleTeamStayAtHome]);
});
it('should evaluate scenario 1', async () => {
const facts = { team: { members: [frank, michael] }, weather: good };
await rools.evaluate(facts);
expect(facts.team.mood).to.be.equal('great');
expect(facts.team.goWalking).to.be.equal(true);
});
it('should evaluate scenario 2', async () => {
const facts = { team: { members: [frank, michael] }, weather: bad };
await rools.evaluate(facts);
expect(facts.team.mood).to.be.equal('great');
expect(facts.team.stayAtHome).to.be.equal(true);
});
});