Skip to content

Commit e99cdf1

Browse files
committed
Added Runtime evaluateExpression tests
1 parent df0eda4 commit e99cdf1

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
const expect = require('chai').expect;
4+
const Runtime = require('../../src/Runtime');
5+
const nb = require('../nodeBuilder');
6+
7+
const runtime = new Runtime();
8+
9+
runtime.input = { foo: 'bar' };
10+
11+
describe('Runtime.evaluateExpression', function() {
12+
it('should return on binary operator', function() {
13+
expect(runtime.evaluateExpression(nb.andConditional(nb.value(true), nb.value(false)))).to.be.false;
14+
});
15+
16+
it('should return on unary operator', function() {
17+
expect(runtime.evaluateExpression(nb.notConditional(nb.value(true)))).to.be.false;
18+
});
19+
20+
it('should return on value expression', function() {
21+
expect(runtime.evaluateExpression(nb.value('foo'))).to.equal('foo');
22+
});
23+
24+
it('should return on value expression', function() {
25+
expect(runtime.evaluateExpression(nb.variable('foo'))).to.equal('bar');
26+
});
27+
28+
it('should error on unknown expression', function() {
29+
expect(() => runtime.evaluateExpression(nb.invalidExpression())).to.throw(/Unknown expression type:/);
30+
});
31+
});

0 commit comments

Comments
 (0)