MCPcopy Index your code
hub / github.com/CacheControl/json-rules-engine / setup

Function setup

test/engine-rule-priority.js:28–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 })
27
28 function setup () {
29 const factSpy = sandbox.stub().returns(22)
30 const eventSpy = sandbox.spy()
31 engine = engineFactory()
32
33 const highPriorityRule = factories.rule({ conditions, event: midPriorityEvent, priority: 50 })
34 engine.addRule(highPriorityRule)
35
36 const midPriorityRule = factories.rule({ conditions, event: highPriorityEvent, priority: 100 })
37 engine.addRule(midPriorityRule)
38
39 const lowPriorityRule = factories.rule({ conditions, event: lowestPriorityEvent, priority: 1 })
40 engine.addRule(lowPriorityRule)
41
42 engine.addFact('age', factSpy)
43 engine.on('success', eventSpy)
44 }
45
46 it('runs the rules in order of priority', () => {
47 setup()

Callers 1

Calls 2

addRuleMethod · 0.80
addFactMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…