Skip to content

Commit e2abf21

Browse files
author
Vikas Agarwal
committed
Extra test cases for expression evaluator
1 parent 3cf17cf commit e2abf21

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/helpers/dependentQuestionsHelper.spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,37 @@ describe('Evaluate', () => {
9797
})
9898
})
9999

100+
describe('logical operators', () => {
101+
102+
it('contains \'a\' && hasLength (true)', () => {
103+
const expression = '(someArrayWithText contains \'a\') && (someArrayWithText hasLength 3)'
104+
const result = evaluate(expression, testData)
105+
106+
result.should.equal(true)
107+
})
108+
109+
it('contains \'a\' && hasLength (true) && contains \'b\'', () => {
110+
const expression = 'someArrayWithText contains \'a\' && someArrayWithText hasLength 3 && someArrayWithText contains \'b\''
111+
const result = evaluate(expression, testData)
112+
113+
result.should.equal(true)
114+
})
115+
116+
it('contains \'a\' && hasLength (false)', () => {
117+
const expression = '(someArrayWithText contains \'a\') && (someArrayWithText hasLength 2)'
118+
const result = evaluate(expression, testData)
119+
120+
result.should.equal(false)
121+
})
122+
123+
it('contains \'a\' && hasLength (false) && contains \'b\'', () => {
124+
const expression = '((someArrayWithText contains \'a\') && (someArrayWithText hasLength 1) && (someArrayWithText contains \'b\'))'
125+
const result = evaluate(expression, testData)
126+
127+
result.should.equal(false)
128+
})
129+
})
130+
100131
describe('expression format', () => {
101132
it('no spaces near parenthesis', () => {
102133
const expression = 'someArray contains (a + b) * 2'

0 commit comments

Comments
 (0)