-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathstreamTest.js
More file actions
71 lines (55 loc) · 1.62 KB
/
streamTest.js
File metadata and controls
71 lines (55 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import gremlin from '../';
describe('.stream()', function() {
it('should emit `data` events with a chunk of results and the raw response', function(done) {
var client = gremlin.createClient();
var s = client.stream(function() { g.V(); });
var results = [];
s.on('data', function(result) {
results.push(result);
});
s.on('end', function() {
results.length.should.equal(6);
done();
});
});
it('should handle bound parameters', function(done) {
var client = gremlin.createClient();
var s = client.stream('g.V(x)', { x: 1 });
s.on('data', function(result) {
result.id.should.equal(1);
});
s.on('end', function() {
done();
});
});
it('should handle optional args', function(done) {
var client = gremlin.createClient();
var s = client.stream('g.V(1)', null, { args: { language: 'nashorn' }});
s.on('data', function(result) {
result.id.should.equal(1);
});
s.on('end', function() {
done();
});
});
it('should handle bindings and optional args', function(done) {
var client = gremlin.createClient();
var s = client.stream('g.V(id)', { id : 1 }, { args: { language: 'nashorn' }});
s.on('data', function(result) {
result.id.should.equal(1);
});
s.on('end', function() {
done();
});
});
it('should handle errors', function(done) {
var client = gremlin.createClient();
// pass a buggy script (missing parenthese)
var script = 'g.V(';
var s = client.stream(script);
s.on('error', function(err) {
(err === null).should.be.false;
done();
});
});
});