@@ -3,19 +3,15 @@ Label = require('../src/statistics').Label,
33RedisGraphAPI = require ( '../src/redisGraph' ) ;
44
55describe ( 'RedisGraphAPI Test' , ( ) => {
6- const api = new RedisGraphAPI ( "social" ) ;
7-
6+ const api = new RedisGraphAPI ( "social" ) ;
7+
88 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 ( ) ;
1410 } ) ;
1511
16- it ( 'test Create Node' , ( done ) => {
12+ it ( 'test Create Node' , ( ) => {
1713 // Create a node
18- api . query ( "CREATE ({name:'roi',age:32})" )
14+ return api . query ( "CREATE ({name:'roi',age:32})" )
1915 . then ( ( result ) => {
2016 assert . ok ( ! result . hasNext ( ) ) ;
2117 assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
@@ -24,56 +20,53 @@ describe('RedisGraphAPI Test', () =>{
2420 assert . ifError ( result . getStatistics ( ) . getStringValue ( Label . RELATIONSHIPS_DELETED ) ) ;
2521 assert . equal ( 2 , result . getStatistics ( ) . propertiesSet ( ) ) ;
2622 assert . ok ( result . getStatistics ( ) . getStringValue ( Label . QUERY_INTERNAL_EXECUTION_TIME ) ) ;
27- done ( ) ;
2823 } ) ;
2924 } ) ;
3025
31- it ( 'test Create Labeled Node' , ( done ) => {
26+ it ( 'test Create Labeled Node' , ( ) => {
3227 // 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})" )
3429 . then ( ( result ) => {
3530 assert . ok ( ! result . hasNext ( ) ) ;
3631 assert . equal ( "1" , result . getStatistics ( ) . getStringValue ( Label . NODES_CREATED ) ) ;
3732 assert . equal ( "2" , result . getStatistics ( ) . getStringValue ( Label . PROPERTIES_SET ) ) ;
3833 assert . ok ( result . getStatistics ( ) . getStringValue ( Label . QUERY_INTERNAL_EXECUTION_TIME ) ) ;
39- done ( ) ;
4034 } ) ;
4135 } ) ;
4236
43- it ( 'test Connect Nodes' , ( done ) => {
37+ it ( 'test Connect Nodes' , ( ) => {
4438 // Create both source and destination nodes
4539 let createResult1 = api . query ( "CREATE (:person{name:'roi',age:32})" ) ;
4640 let createResult2 = api . query ( "CREATE (:person{name:'amit',age:30})" ) ;
4741
4842 // 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)" )
5044 . then ( ( matchResult ) => {
5145 assert . ok ( ! matchResult . hasNext ( ) ) ;
5246 assert . ifError ( matchResult . getStatistics ( ) . getStringValue ( Label . NODES_CREATED ) ) ;
5347 assert . ifError ( matchResult . getStatistics ( ) . getStringValue ( Label . PROPERTIES_SET ) ) ;
5448 assert . equal ( 1 , matchResult . getStatistics ( ) . relationshipsCreated ( ) ) ;
5549 assert . equal ( 0 , matchResult . getStatistics ( ) . relationshipsDeleted ( ) ) ;
5650 assert . ok ( matchResult . getStatistics ( ) . getStringValue ( Label . QUERY_INTERNAL_EXECUTION_TIME ) ) ;
57- done ( ) ;
5851 } ) ;
5952 } ) ;
6053
61- it ( 'test Query' , ( done ) => {
54+ it ( 'test Query' , ( ) => {
6255
6356 // 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 ) => {
6659 return api . query ( "CREATE (:qhuman{name:'amit',age:30})" ) ;
6760 } )
6861 . then ( ( create2Result ) => {
6962 // 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)" ) ;
7164 } )
7265 . then ( ( connectResult ) => {
7366 // Query
7467 return api . query ( "MATCH (a:qhuman)-[knows]->(:qhuman) RETURN a" ) ;
7568 } )
76- . then ( ( resultSet ) => {
69+ . then ( ( resultSet ) => {
7770 assert . ok ( resultSet . hasNext ( ) ) ;
7871 assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
7972 assert . equal ( 0 , resultSet . getStatistics ( ) . propertiesSet ( ) ) ;
@@ -84,7 +77,6 @@ describe('RedisGraphAPI Test', () =>{
8477 let record = resultSet . next ( ) ;
8578 assert . equal ( "roi" , record . getString ( 1 ) ) ;
8679 assert . equal ( "32.000000" , record . getString ( 0 ) ) ;
87- done ( ) ;
8880 } ) ;
8981 } ) ;
9082} )
0 commit comments