Skip to content

Commit 32f8147

Browse files
author
Cache Hamm
committed
upgrade dev dependencies
1 parent e20c899 commit 32f8147

19 files changed

Lines changed: 107 additions & 110 deletions

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,23 @@
4545
"devDependencies": {
4646
"babel-cli": "^6.4.5",
4747
"babel-core": "~6.9.1",
48-
"babel-eslint": "^5.0.0-beta6",
48+
"babel-eslint": "^7.1.1",
4949
"babel-loader": "~6.2.4",
5050
"babel-plugin-transform-async-to-generator": "^6.4.6",
5151
"babel-polyfill": "~6.7.4",
5252
"babel-preset-es2015": "~6.9.0",
5353
"babel-preset-stage-0": "~6.5.0",
5454
"babel-register": "^6.4.3",
55-
"chai": "3.4.1",
56-
"chai-as-promised": "^5.2.0",
55+
"chai": "^3.5.0",
56+
"chai-as-promised": "^6.0.0",
5757
"colors": "~1.1.2",
58-
"mocha": "3.2.0",
58+
"dirty-chai": "1.2.2",
59+
"mocha": "^3.2.0",
5960
"regenerator": "~0.8.46",
6061
"sinon": "^1.17.2",
6162
"sinon-chai": "^2.8.0",
6263
"snazzy": "^2.0.1",
63-
"standard": "^5.4.1"
64+
"standard": "^9.0.0"
6465
},
6566
"dependencies": {
6667
"debug": "2.2.0",

src/condition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class Condition {
6262
/**
6363
* Interprets .value as either a primitive, or if a fact, retrieves the fact value
6464
*/
65-
async _getValue(almanac) {
65+
async _getValue (almanac) {
6666
let value = this.value
6767
if (isPlainObject(value) && value.hasOwnProperty('fact')) { // value: { fact: 'xyz' }
6868
value = await almanac.factValue(value.fact, value.params, value.path)

src/rule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Rule extends EventEmitter {
110110
let priority = condition.priority
111111
if (!priority) {
112112
let fact = this.engine.getFact(condition.fact)
113-
priority = fact && fact.priority || 1
113+
priority = (fact && fact.priority) || 1
114114
}
115115
if (!sets[priority]) sets[priority] = []
116116
sets[priority].push(condition)

test/almanac.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('Almanac', () => {
113113
it('honors facts with caching disabled', (done) => {
114114
setup(new Fact('id', 1, { cache: false }))
115115
let promise = almanac._setFactValue(fact, {}, FACT_VALUE)
116-
expect(almanac.factResultsCache.values().next().value).to.be.undefined
116+
expect(almanac.factResultsCache.values().next().value).to.be.undefined()
117117
promise.then(value => expect(value).to.equal(FACT_VALUE)).then(_ => done()).catch(done)
118118
})
119119
})
@@ -135,15 +135,15 @@ describe('Almanac', () => {
135135
almanac.factValue('foo')
136136
almanac.factValue('foo')
137137
almanac.factValue('foo')
138-
expect(factSpy).to.have.been.calledThrice
138+
expect(factSpy).to.have.been.calledThrice()
139139
})
140140

141141
it('evaluates the fact once when fact caching is on', () => {
142142
setup({ cache: true })
143143
almanac.factValue('foo')
144144
almanac.factValue('foo')
145145
almanac.factValue('foo')
146-
expect(factSpy).to.have.been.calledOnce
146+
expect(factSpy).to.have.been.calledOnce()
147147
})
148148
})
149149
})

test/condition.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ describe('Condition', () => {
7676
context('validations', () => {
7777
beforeEach(() => setup())
7878
it('throws when missing an almanac', () => {
79-
return expect(condition.evaluate(undefined, operators)).to.be.rejectedWith('Error: almanac required')
79+
return expect(condition.evaluate(undefined, operators)).to.be.rejectedWith('almanac required')
8080
})
8181
it('throws when missing operators', () => {
82-
return expect(condition.evaluate(almanac, undefined)).to.be.rejectedWith('Error: operatorMap required')
82+
return expect(condition.evaluate(almanac, undefined)).to.be.rejectedWith('operatorMap required')
8383
})
8484
it('throws when run against a boolean operator', () => {
8585
condition.all = []
86-
return expect(condition.evaluate(almanac, operators)).to.be.rejectedWith('Error: Cannot evaluate() a boolean condition')
86+
return expect(condition.evaluate(almanac, operators)).to.be.rejectedWith('Cannot evaluate() a boolean condition')
8787
})
8888
})
8989

@@ -102,17 +102,17 @@ describe('Condition', () => {
102102
})
103103

104104
it('evaluates "in"', async () => {
105-
setup({ operator: 'in', value: [5, 10, 15, 20]}, 15)
105+
setup({ operator: 'in', value: [5, 10, 15, 20] }, 15)
106106
expect(await condition.evaluate(almanac, operators)).to.equal(true)
107-
setup({ operator: 'in', value: [5, 10, 15, 20]}, 99)
107+
setup({ operator: 'in', value: [5, 10, 15, 20] }, 99)
108108
expect(await condition.evaluate(almanac, operators)).to.equal(false)
109109
})
110110

111111
it('evaluates "contains"', async () => {
112112
setup({ operator: 'contains', value: 10 }, [5, 10, 15])
113-
expect(await condition.evaluate(almanac,operators)).to.equal(true)
113+
expect(await condition.evaluate(almanac, operators)).to.equal(true)
114114
setup({ operator: 'contains', value: 10 }, [1, 2, 3])
115-
expect(await condition.evaluate(almanac,operators)).to.equal(false)
115+
expect(await condition.evaluate(almanac, operators)).to.equal(false)
116116
})
117117

118118
it('evaluates "doesNotContain"', async () => {
@@ -170,7 +170,7 @@ describe('Condition', () => {
170170
setup({ operator: 'contains' }, null)
171171
expect(await condition.evaluate(almanac, operators)).to.equal(false)
172172
setup({ operator: 'doesNotContain' }, null)
173-
expect(await condition.evaluate(almanac,operators)).to.equal(false)
173+
expect(await condition.evaluate(almanac, operators)).to.equal(false)
174174
})
175175

176176
it('returns false when using comparison operators with null', async () => {
@@ -209,7 +209,7 @@ describe('Condition', () => {
209209
expect(await condition.evaluate(almanac, operators)).to.equal(false)
210210
})
211211

212-
it('ignores "path" when non-objects are returned by the fact', async () => {
212+
it('ignores "path" when non-objects are returned by the fact', async () => {
213213
let ageFact = new Fact('age', 50)
214214
let facts = new Map([[ageFact.id, ageFact]])
215215
let almanac = new Almanac(facts)
@@ -282,7 +282,7 @@ describe('Condition', () => {
282282
}
283283
}
284284
it('recursively parses nested conditions', () => {
285-
expect(() => new Condition(complexCondition())).to.not.throw
285+
expect(() => new Condition(complexCondition())).to.not.throw()
286286
})
287287

288288
it('throws if a nested condition is invalid', () => {

test/engine-cache.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ describe('Engine: cache', () => {
3535
it('loads facts once and caches the results for future use', async () => {
3636
setup({cache: true})
3737
await engine.run()
38-
expect(eventSpy).to.have.been.calledThrice
39-
expect(factSpy).to.have.been.calledOnce
38+
expect(eventSpy).to.have.been.calledThrice()
39+
expect(factSpy).to.have.been.calledOnce()
4040
})
4141

4242
it('allows caching to be turned off', async () => {
4343
setup({cache: false})
4444
await engine.run()
45-
expect(eventSpy).to.have.been.calledThrice
46-
expect(factSpy).to.have.been.calledThrice
45+
expect(eventSpy).to.have.been.calledThrice()
46+
expect(factSpy).to.have.been.calledThrice()
4747
})
4848
})

test/engine-controls.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ describe('Engine: fact priority', () => {
5050
engine.stop()
5151
})
5252
await engine.run()
53-
expect(eventSpy).to.have.been.calledOnce
54-
expect(ageStub).to.have.been.calledOnce
55-
expect(segmentStub).to.not.have.been.called
53+
expect(eventSpy).to.have.been.calledOnce()
54+
expect(ageStub).to.have.been.calledOnce()
55+
expect(segmentStub).to.not.have.been.called()
5656
})
5757
})
5858
})

test/engine-fact-comparison.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use strict'
22

33
import engineFactory from '../src/index'
4-
import { Fact } from '../src/index'
54
import sinon from 'sinon'
65

76
describe('Engine: fact to fact comparison', () => {
87
let engine
98
let eventSpy = sinon.spy()
109

11-
function setup(conditions) {
10+
function setup (conditions) {
1211
let event = { type: 'success-event' }
1312
eventSpy.reset()
1413
engine = engineFactory()
@@ -30,7 +29,7 @@ describe('Engine: fact to fact comparison', () => {
3029
it('allows a fact to retrieve other fact values', async () => {
3130
setup(constantCondition)
3231
await engine.run({ height: 1, width: 2 })
33-
expect(eventSpy).to.have.been.calledOnce
32+
expect(eventSpy).to.have.been.calledOnce()
3433

3534
eventSpy.reset()
3635

@@ -66,7 +65,7 @@ describe('Engine: fact to fact comparison', () => {
6665
return params.multiplier * width
6766
})
6867
await engine.run({ height: 5, width: 10 })
69-
expect(eventSpy).to.have.been.calledOnce
68+
expect(eventSpy).to.have.been.calledOnce()
7069

7170
eventSpy.reset()
7271

@@ -80,7 +79,7 @@ describe('Engine: fact to fact comparison', () => {
8079
all: [{
8180
fact: 'widthMultiplier',
8281
params: {
83-
multiplier: 2,
82+
multiplier: 2
8483
},
8584
path: '.feet',
8685
operator: 'equal',
@@ -104,7 +103,7 @@ describe('Engine: fact to fact comparison', () => {
104103
return { feet: params.multiplier * width }
105104
})
106105
await engine.run({ height: 5, width: 10 })
107-
expect(eventSpy).to.have.been.calledOnce
106+
expect(eventSpy).to.have.been.calledOnce()
108107

109108
eventSpy.reset()
110109

test/engine-fact-priority.test.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ describe('Engine: fact priority', () => {
5151
setup(allCondition)
5252
ageStub.returns(10) // fail
5353
await engine.run()
54-
expect(failureSpy).to.have.been.called
55-
expect(eventSpy).to.not.have.been.called
56-
expect(ageStub).to.have.been.calledOnce
57-
expect(segmentStub).to.not.have.been.called
58-
expect(accountTypeStub).to.not.have.been.called
54+
expect(failureSpy).to.have.been.called()
55+
expect(eventSpy).to.not.have.been.called()
56+
expect(ageStub).to.have.been.calledOnce()
57+
expect(segmentStub).to.not.have.been.called()
58+
expect(accountTypeStub).to.not.have.been.called()
5959
})
6060

6161
it('stops on the first fact to fail, part 2', async () => {
6262
setup(allCondition)
6363
ageStub.returns(20) // pass
6464
segmentStub.returns('android') // fail
6565
await engine.run()
66-
expect(failureSpy).to.have.been.called
67-
expect(eventSpy).to.not.have.been.called
68-
expect(ageStub).to.have.been.calledOnce
69-
expect(segmentStub).to.have.been.calledOnce
70-
expect(accountTypeStub).to.not.have.been.called
66+
expect(failureSpy).to.have.been.called()
67+
expect(eventSpy).to.not.have.been.called()
68+
expect(ageStub).to.have.been.calledOnce()
69+
expect(segmentStub).to.have.been.calledOnce()
70+
expect(accountTypeStub).to.not.have.been.called()
7171
})
7272

7373
describe('sub-conditions', () => {
@@ -96,11 +96,11 @@ describe('Engine: fact priority', () => {
9696
ageStub.returns(20) // pass
9797
segmentStub.returns('android') // fail
9898
await engine.run()
99-
expect(failureSpy).to.have.been.called
100-
expect(eventSpy).to.not.have.been.called
101-
expect(ageStub).to.have.been.calledOnce
102-
expect(segmentStub).to.have.been.calledOnce
103-
expect(accountTypeStub).to.not.have.been.called
99+
expect(failureSpy).to.have.been.called()
100+
expect(eventSpy).to.not.have.been.called()
101+
expect(ageStub).to.have.been.calledOnce()
102+
expect(segmentStub).to.have.been.calledOnce()
103+
expect(accountTypeStub).to.not.have.been.called()
104104
})
105105
})
106106
})
@@ -125,23 +125,23 @@ describe('Engine: fact priority', () => {
125125
setup(anyCondition)
126126
ageStub.returns(20) // succeed
127127
await engine.run()
128-
expect(eventSpy).to.have.been.calledOnce
129-
expect(failureSpy).to.not.have.been.called
130-
expect(ageStub).to.have.been.calledOnce
131-
expect(segmentStub).to.not.have.been.called
132-
expect(accountTypeStub).to.not.have.been.called
128+
expect(eventSpy).to.have.been.calledOnce()
129+
expect(failureSpy).to.not.have.been.called()
130+
expect(ageStub).to.have.been.calledOnce()
131+
expect(segmentStub).to.not.have.been.called()
132+
expect(accountTypeStub).to.not.have.been.called()
133133
})
134134

135135
it('short circuits on the first fact to fail, part 2', async () => {
136136
setup(anyCondition)
137137
ageStub.returns(10) // fail
138138
segmentStub.returns('human') // pass
139139
await engine.run()
140-
expect(eventSpy).to.have.been.calledOnce
141-
expect(failureSpy).to.not.have.been.called
142-
expect(ageStub).to.have.been.calledOnce
143-
expect(segmentStub).to.have.been.calledOnce
144-
expect(accountTypeStub).to.not.have.been.called
140+
expect(eventSpy).to.have.been.calledOnce()
141+
expect(failureSpy).to.not.have.been.called()
142+
expect(ageStub).to.have.been.calledOnce()
143+
expect(segmentStub).to.have.been.calledOnce()
144+
expect(accountTypeStub).to.not.have.been.called()
145145
})
146146

147147
describe('sub-conditions', () => {
@@ -170,11 +170,11 @@ describe('Engine: fact priority', () => {
170170
ageStub.returns(20) // success
171171
segmentStub.returns('human') // success
172172
await engine.run()
173-
expect(failureSpy).to.not.have.been.called
174-
expect(eventSpy).to.have.been.called
175-
expect(ageStub).to.have.been.calledOnce
176-
expect(segmentStub).to.have.been.calledOnce
177-
expect(accountTypeStub).to.not.have.been.called
173+
expect(failureSpy).to.not.have.been.called()
174+
expect(eventSpy).to.have.been.called()
175+
expect(ageStub).to.have.been.calledOnce()
176+
expect(segmentStub).to.have.been.calledOnce()
177+
expect(accountTypeStub).to.not.have.been.called()
178178
})
179179
})
180180
})

test/engine-fact.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ describe('Engine: fact evaluation', () => {
9292
})
9393
setup(conditions, { allowUndefinedFacts: true })
9494
await engine.run()
95-
expect(successSpy).to.have.been.called
96-
expect(failureSpy).to.not.have.been.called
95+
expect(successSpy).to.have.been.called()
96+
expect(failureSpy).to.not.have.been.called()
9797
})
9898

9999
it('emits "failure" when the condition fails', async () => {
@@ -106,8 +106,8 @@ describe('Engine: fact evaluation', () => {
106106
conditions.any[0].params.eligibilityId = 2
107107
setup(conditions, { allowUndefinedFacts: true })
108108
await engine.run()
109-
expect(successSpy).to.not.have.been.called
110-
expect(failureSpy).to.have.been.called
109+
expect(successSpy).to.not.have.been.called()
110+
expect(failureSpy).to.have.been.called()
111111
})
112112
})
113113
})
@@ -125,7 +125,7 @@ describe('Engine: fact evaluation', () => {
125125
conditions.any[0].params.eligibilityId = 2
126126
setup(conditions)
127127
await engine.run()
128-
expect(successSpy).to.not.have.been.called
128+
expect(successSpy).to.not.have.been.called()
129129
})
130130
})
131131

@@ -154,7 +154,7 @@ describe('Engine: fact evaluation', () => {
154154
failureCondition.any[0].params.eligibilityId = 2
155155
setup(failureCondition)
156156
await engine.run()
157-
expect(successSpy).to.not.have.been.called
157+
expect(successSpy).to.not.have.been.called()
158158
})
159159

160160
it('emits when complex object paths meet the conditions', async () => {
@@ -210,7 +210,7 @@ describe('Engine: fact evaluation', () => {
210210
}
211211
engine.addFact('eligibilityField', eligibilityField)
212212
await engine.run()
213-
expect(successSpy).to.have.been.called
213+
expect(successSpy).to.have.been.called()
214214
})
215215
})
216216

@@ -222,7 +222,7 @@ describe('Engine: fact evaluation', () => {
222222
}
223223
engine.addFact('eligibilityField', eligibilityField)
224224
await engine.run()
225-
expect(successSpy).to.have.been.called
225+
expect(successSpy).to.have.been.called()
226226
})
227227

228228
it('works with synchronous, non-promise evaluations that are falsey', async () => {
@@ -232,7 +232,7 @@ describe('Engine: fact evaluation', () => {
232232
}
233233
engine.addFact('eligibilityField', eligibilityField)
234234
await engine.run()
235-
expect(successSpy).to.not.have.been.called
235+
expect(successSpy).to.not.have.been.called()
236236
})
237237
})
238238
})

0 commit comments

Comments
 (0)