@@ -3,19 +3,15 @@ Label = require('../src/statistics').Label,
3
3
RedisGraphAPI = require ( '../src/redisGraph' ) ;
4
4
5
5
describe ( 'RedisGraphAPI Test' , ( ) => {
6
- const api = new RedisGraphAPI ( "social" ) ;
7
-
6
+ const api = new RedisGraphAPI ( "social" ) ;
7
+
8
8
beforeEach ( ( ) => {
9
- //api.deleteGraph(); - TODO add this back once we implement this API
10
-
11
- // Method method = RedisGraphAPI.class.getDeclaredMethod("_conn");
12
- // method.setAccessible(true);
13
- // ((Jedis)method.invoke(api)).flushDB();
9
+ return api . deleteGraph ( ) ;
14
10
} ) ;
15
11
16
- it ( 'test Create Node' , ( done ) => {
12
+ it ( 'test Create Node' , ( ) => {
17
13
// Create a node
18
- api . query ( "CREATE ({name:'roi',age:32})" )
14
+ return api . query ( "CREATE ({name:'roi',age:32})" )
19
15
. then ( ( result ) => {
20
16
assert . ok ( ! result . hasNext ( ) ) ;
21
17
assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
@@ -24,56 +20,53 @@ describe('RedisGraphAPI Test', () =>{
24
20
assert . ifError ( result . getStatistics ( ) . getStringValue ( Label . RELATIONSHIPS_DELETED ) ) ;
25
21
assert . equal ( 2 , result . getStatistics ( ) . propertiesSet ( ) ) ;
26
22
assert . ok ( result . getStatistics ( ) . getStringValue ( Label . QUERY_INTERNAL_EXECUTION_TIME ) ) ;
27
- done ( ) ;
28
23
} ) ;
29
24
} ) ;
30
25
31
- it ( 'test Create Labeled Node' , ( done ) => {
26
+ it ( 'test Create Labeled Node' , ( ) => {
32
27
// Create a node with a label
33
- api . query ( "CREATE (:human{name:'danny',age:12})" )
28
+ return api . query ( "CREATE (:human{name:'danny',age:12})" )
34
29
. then ( ( result ) => {
35
30
assert . ok ( ! result . hasNext ( ) ) ;
36
31
assert . equal ( "1" , result . getStatistics ( ) . getStringValue ( Label . NODES_CREATED ) ) ;
37
32
assert . equal ( "2" , result . getStatistics ( ) . getStringValue ( Label . PROPERTIES_SET ) ) ;
38
33
assert . ok ( result . getStatistics ( ) . getStringValue ( Label . QUERY_INTERNAL_EXECUTION_TIME ) ) ;
39
- done ( ) ;
40
34
} ) ;
41
35
} ) ;
42
36
43
- it ( 'test Connect Nodes' , ( done ) => {
37
+ it ( 'test Connect Nodes' , ( ) => {
44
38
// Create both source and destination nodes
45
39
let createResult1 = api . query ( "CREATE (:person{name:'roi',age:32})" ) ;
46
40
let createResult2 = api . query ( "CREATE (:person{name:'amit',age:30})" ) ;
47
41
48
42
// Connect source and destination nodes.
49
- api . query ( "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[knows]->(a)" )
43
+ return api . query ( "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[knows]->(a)" )
50
44
. then ( ( matchResult ) => {
51
45
assert . ok ( ! matchResult . hasNext ( ) ) ;
52
46
assert . ifError ( matchResult . getStatistics ( ) . getStringValue ( Label . NODES_CREATED ) ) ;
53
47
assert . ifError ( matchResult . getStatistics ( ) . getStringValue ( Label . PROPERTIES_SET ) ) ;
54
48
assert . equal ( 1 , matchResult . getStatistics ( ) . relationshipsCreated ( ) ) ;
55
49
assert . equal ( 0 , matchResult . getStatistics ( ) . relationshipsDeleted ( ) ) ;
56
50
assert . ok ( matchResult . getStatistics ( ) . getStringValue ( Label . QUERY_INTERNAL_EXECUTION_TIME ) ) ;
57
- done ( ) ;
58
51
} ) ;
59
52
} ) ;
60
53
61
- it ( 'test Query' , ( done ) => {
54
+ it ( 'test Query' , ( ) => {
62
55
63
56
// Create both source and destination nodes
64
- api . query ( "CREATE (:qhuman{name:'roi',age:32})" )
65
- . then ( ( create1Result ) => {
57
+ return api . query ( "CREATE (:qhuman{name:'roi',age:32})" )
58
+ . then ( ( create1Result ) => {
66
59
return api . query ( "CREATE (:qhuman{name:'amit',age:30})" ) ;
67
60
} )
68
61
. then ( ( create2Result ) => {
69
62
// Connect source and destination nodes.
70
- return api . query ( "MATCH (a:qhuman), (b:qhuman) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[knows]->(b)" ) ;
63
+ return api . query ( "MATCH (a:qhuman), (b:qhuman) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[knows]->(b)" ) ;
71
64
} )
72
65
. then ( ( connectResult ) => {
73
66
// Query
74
67
return api . query ( "MATCH (a:qhuman)-[knows]->(:qhuman) RETURN a" ) ;
75
68
} )
76
- . then ( ( resultSet ) => {
69
+ . then ( ( resultSet ) => {
77
70
assert . ok ( resultSet . hasNext ( ) ) ;
78
71
assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
79
72
assert . equal ( 0 , resultSet . getStatistics ( ) . propertiesSet ( ) ) ;
@@ -84,7 +77,6 @@ describe('RedisGraphAPI Test', () =>{
84
77
let record = resultSet . next ( ) ;
85
78
assert . equal ( "roi" , record . getString ( 1 ) ) ;
86
79
assert . equal ( "32.000000" , record . getString ( 0 ) ) ;
87
- done ( ) ;
88
80
} ) ;
89
81
} ) ;
90
82
} )
0 commit comments