Skip to content

Commit 5101882

Browse files
author
Aries Yuwono
committed
added test cases
1 parent 63016aa commit 5101882

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test-complete/nodejs-javascript-eval-params.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,43 @@ describe('Javascript eval params test', function(){
3939
}, done);
4040
});
4141

42+
it('should do javascript eval with params on stream', function(done){
43+
dbEval.eval('var num1;' +
44+
'var num2;' +
45+
'num1 + num2;',
46+
{num1:2, num2:3}
47+
).
48+
stream().
49+
on('data', function(data) {
50+
//console.log(data);
51+
data.value.should.equal(5);
52+
}).
53+
on('end', function() {
54+
done();
55+
}, done);
56+
});
57+
58+
it('should do javascript eval with params and transaction', function(done){
59+
var tid = 0;
60+
61+
dbEval.transactions.open({transactionName: 'evalTransaction', timeLimit: 60})
62+
.result(function(response) {
63+
tid = response.txid;
64+
return dbEval.eval({
65+
source: 'var num1; var num2; num1 + num2;',
66+
variables: {num1:2, num2:3},
67+
txid: tid
68+
}).result();
69+
})
70+
.then(function(response) {
71+
//console.log(response);
72+
response[0].value.should.equal(5);
73+
return dbEval.transactions.commit(tid).result();
74+
})
75+
.then(function(response) {
76+
//console.log(response);
77+
done();
78+
}, done);
79+
});
80+
4281
});

0 commit comments

Comments
 (0)