Skip to content

Commit ea76069

Browse files
author
Cache Hamm
committed
jsonpath scalar result test
1 parent c858ec0 commit ea76069

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

test/engine-fact.test.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ async function eligibilityData (params, engine) {
2727
occupantHistory: [
2828
{ name: 'Joe', year: 2011 },
2929
{ name: 'Jane', year: 2013 }
30+
],
31+
currentOccupants: [
32+
{ name: 'Larry', year: 2020 },
3033
]
3134
}
3235
if (params.eligibilityId === 1) {
@@ -168,15 +171,27 @@ describe('Engine: fact evaluation', () => {
168171
expect(successSpy).to.not.have.been.called()
169172
})
170173

171-
it('can extract an array, allowing it to be used in concert with array operators', async () => {
172-
const complexCondition = conditions()
173-
complexCondition.any[0].path = '$.address.occupantHistory[*].year'
174-
complexCondition.any[0].value = 2011
175-
complexCondition.any[0].operator = 'contains'
176-
setup(complexCondition)
177-
await engine.run()
178-
expect(successSpy).to.have.been.calledWith(event)
179-
})
174+
describe.only('arrays', () => {
175+
it('can extract an array, allowing it to be used in concert with array operators', async () => {
176+
const complexCondition = conditions()
177+
complexCondition.any[0].path = '$.address.occupantHistory[*].year'
178+
complexCondition.any[0].value = 2011
179+
complexCondition.any[0].operator = 'contains'
180+
setup(complexCondition)
181+
await engine.run()
182+
expect(successSpy).to.have.been.calledWith(event)
183+
})
184+
185+
it('can extract an array with a single element', async () => {
186+
const complexCondition = conditions()
187+
complexCondition.any[0].path = '$.address.currentOccupants[*].year'
188+
complexCondition.any[0].value = 2020
189+
complexCondition.any[0].operator = 'contains'
190+
setup(complexCondition)
191+
await engine.run()
192+
expect(successSpy).to.have.been.calledWith(event)
193+
})
194+
});
180195

181196
context('complex paths', () => {
182197
it('correctly interprets "path" when dynamic facts return objects', async () => {

0 commit comments

Comments
 (0)