-
Notifications
You must be signed in to change notification settings - Fork 664
/
Copy pathtest310.js
94 lines (81 loc) · 2.73 KB
/
test310.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
} else {
__dirname = '.';
}
describe('Test 310 Create graph', function () {
it('1. Create database ', function (done) {
alasql('CREATE DATABASE test310;USE test310');
done();
});
it('2. LIKE selector', function (done) {
var data = [{name: 'Moscow'}, {name: 'St.Petersburg'}, {name: 'Prague'}];
// var res = alasql.parse('CREATE GRAPH #Andrey');
var res = alasql('SEARCH / name LIKE "P%" FROM ?', [data]);
assert.deepEqual(res, ['Prague']);
done();
});
it('3. CREATE GRAPH', function (done) {
// var res = alasql.parse('CREATE GRAPH #Andrey');
var res = alasql('CREATE GRAPH #Andrey');
var res = alasql('CREATE GRAPH #John,#Mary');
var res = alasql('CREATE GRAPH #Anton,#Julia,#Anton >> #John');
var res = alasql('CREATE GRAPH #Victor "Victor Branson"');
var res = alasql('CREATE GRAPH #[John Smith] {age:23, country:"Canada"}');
var res = alasql('CREATE GRAPH #[John Smith] > "loves" > #Mary');
var res = alasql('CREATE GRAPH #Anton > "loves" {power:"too much"} > #Julia');
var res = alasql('SEARCH / VERTEX [$id]');
assert.deepEqual(res, ['Andrey', 'John', 'Mary', 'Anton', 'Julia', 'Victor', 'John Smith']);
done();
});
it('2. RETURNS', function (done) {
var res = alasql('SEARCH RETURNS(country,age AS Age) FROM #[John Smith] ');
assert.deepEqual(res, [{country: 'Canada', Age: 23}]);
done();
});
// it('2. CREATE GRAPH FROM',function(done){
// alasql('CREATE GRAPH FROM GEXF("test310.gexf")');
// done();
// });
// it('3. Gorup operations',function(done){
// alasql('SEARCH EDGE SET(color="black")');
// done();
// });
// it('4. PATH',function(done){
// alasql('SEARCH #1 PATH(#10)');
// alasql('SEARCH #1 PATH(#10) SET(color="red")');
// alasql('SEARCH #1 PATHS(#10)');
// done();
// });
// it('5. D3',function(done){
// alasql('SEARCH VERTEX D3()');
// alasql('SEARCH EDGE D3()');
// done();
// });
// it('6. ALL,ANY,CONCAT',function(done){
// alasql('SEARCH SUM(VERTEX)');
// alasql('SEARCH SUM(EDGE)');
// alasql('SEARCH SUM(EDGE),SUM(VERTEX)'); //?
// alasql('SEARCH CONCAT(SUM(EDGE),SUM(VERTEX))');
// alasql('SEARCH ALL(VERTEX,EDGE)');
// alasql('SEARCH ANY(VERTEX,EDGE)');
// done();
// });
// it('7. = statement',function(done){
// alasql('=1+1');
// alasql('=(SEARCH SUM(VERTEX))');
// alasql('=(SEARCH SUM(EDGE))');
// done();
// });
// it('7. ORDER BY',function(done){
// var data = [{a:1},{a:2},{a:0}];
// var res = alasql('SEARCH a FROM ? ORDER BY _ DESC',[data]);
// assert.deepEqual(res,[2,1,0]);
// done();
// });
it('99. Drop database ', function (done) {
alasql('DROP DATABASE test310');
done();
});
});