@@ -10,34 +10,41 @@ const assert = require("assert"),
1010 deepEqual = require ( "deep-equal" ) ;
1111
1212describe ( "RedisGraphAPI Test" , ( ) => {
13- // Assuming this test is running against redis server at: localhost:6379 with no password.
13+ // Assuming this test is running against redis server at: localhost:6379 with no password.
1414 const api = new RedisGraph ( "social" ) ;
1515
1616 beforeEach ( ( ) => {
1717 return api . deleteGraph ( ) . catch ( ( ) => { } ) ;
1818 } ) ;
1919
20- it ( "test connection from port and host" , async ( ) => {
21- // Assuming this test is running against redis server at: localhost:6379 with no password.
22- let graph = new RedisGraph ( "social" , "127.0.0.1" , 6379 , { password :undefined } ) ;
23- let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
20+ it ( "test connection from port and host" , async ( ) => {
21+ // Assuming this test is running against redis server at: localhost:6379 with no password.
22+ let graph = new RedisGraph ( "social" , "127.0.0.1" , 6379 , {
23+ password : undefined ,
24+ } ) ;
25+ let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
26+ assert . equal ( result . size ( ) , 0 ) ;
2427 assert . ok ( ! result . hasNext ( ) ) ;
25- assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
26- graph . deleteGraph ( ) ;
27- } )
28+ assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
29+ graph . deleteGraph ( ) ;
30+ graph . close ( ) ;
31+ } ) ;
2832
2933 it ( "test connection from client" , async ( ) => {
30- // Assuming this test is running against redis server at: localhost:6379 with no password.
31- let graph = new RedisGraph ( "social" , redis . createClient ( ) ) ;
32- let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
34+ // Assuming this test is running against redis server at: localhost:6379 with no password.
35+ let graph = new RedisGraph ( "social" , redis . createClient ( ) ) ;
36+ let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
37+ assert . equal ( result . size ( ) , 0 ) ;
3338 assert . ok ( ! result . hasNext ( ) ) ;
34- assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
35- graph . deleteGraph ( ) ;
39+ assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
40+ graph . deleteGraph ( ) ;
41+ graph . close ( ) ;
3642 } ) ;
3743
3844 it ( "test Create Node" , async ( ) => {
3945 // Create a node
4046 let result = await api . query ( "CREATE ({name:'roi', age:34})" ) ;
47+ assert . equal ( result . size ( ) , 0 ) ;
4148 assert . ok ( ! result . hasNext ( ) ) ;
4249 assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
4350 assert . ifError (
@@ -71,6 +78,7 @@ describe("RedisGraphAPI Test", () => {
7178 it ( "test Create Labeled Node" , async ( ) => {
7279 // Create a node with a label
7380 let result = await api . query ( "CREATE (:human {name:'danny', age:12})" ) ;
81+ assert . equal ( result . size ( ) , 0 ) ;
7482 assert . ok ( ! result . hasNext ( ) ) ;
7583 assert . equal (
7684 "1" ,
@@ -97,6 +105,7 @@ describe("RedisGraphAPI Test", () => {
97105 "MATCH (a:person {name:'roi'}), \
98106 (b:person {name:'amit'}) CREATE (a)-[:knows]->(b)"
99107 ) ;
108+ assert . equal ( matchResult . size ( ) , 0 ) ;
100109 assert . ok ( ! matchResult . hasNext ( ) ) ;
101110 assert . ifError (
102111 matchResult . getStatistics ( ) . getStringValue ( Label . NODES_CREATED )
@@ -122,6 +131,7 @@ describe("RedisGraphAPI Test", () => {
122131 let resultSet = await api . query (
123132 "MATCH (r:human)-[:knows]->(a:human) RETURN r.age, r.name"
124133 ) ;
134+ assert . equal ( resultSet . size ( ) , 1 ) ;
125135 assert . ok ( resultSet . hasNext ( ) ) ;
126136 assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
127137 assert . equal ( 0 , resultSet . getStatistics ( ) . nodesDeleted ( ) ) ;
@@ -162,7 +172,7 @@ describe("RedisGraphAPI Test", () => {
162172 let resultSet = await api . query (
163173 "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r"
164174 ) ;
165-
175+ assert . equal ( resultSet . size ( ) , 1 ) ;
166176 assert . ok ( resultSet . hasNext ( ) ) ;
167177 assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
168178 assert . equal ( 0 , resultSet . getStatistics ( ) . nodesDeleted ( ) ) ;
@@ -199,6 +209,7 @@ describe("RedisGraphAPI Test", () => {
199209 it ( "test null value to string" , async ( ) => {
200210 await api . query ( "CREATE ( {nullValue:null} )" ) ;
201211 let resultSet = await api . query ( "MATCH (n) RETURN n.nullValue" ) ;
212+ assert . equal ( resultSet . size ( ) , 1 ) ;
202213 assert . ok ( resultSet . hasNext ( ) ) ;
203214 let record = resultSet . next ( ) ;
204215 assert . equal ( undefined , record . get ( 0 ) ) ;
@@ -217,6 +228,7 @@ describe("RedisGraphAPI Test", () => {
217228 "MATCH (a:person)-[:knows]->(:person) RETURN a"
218229 ) ;
219230
231+ assert . equal ( resultSet . size ( ) , 0 ) ;
220232 assert . ok ( ! resultSet . hasNext ( ) ) ;
221233 assert . equal ( resultSet . getHeader ( ) [ 0 ] , "a" ) ;
222234 assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
@@ -236,24 +248,27 @@ describe("RedisGraphAPI Test", () => {
236248 await api . query ( "CREATE (:person{name:'a',age:32,array:[0,1,2]})" ) ;
237249 await api . query ( "CREATE (:person{name:'b',age:30,array:[3,4,5]})" ) ;
238250 let resultSet = await api . query ( "WITH [0,1,2] as x return x" ) ;
251+
252+ assert . equal ( resultSet . size ( ) , 1 ) ;
239253 assert . ok ( resultSet . hasNext ( ) ) ;
240254 assert . deepStrictEqual ( [ "x" ] , resultSet . getHeader ( ) ) ;
241255 let record = resultSet . next ( ) ;
242256 assert . deepStrictEqual ( [ 0 , 1 , 2 ] , record . get ( 0 ) ) ;
243257 assert . ok ( ! resultSet . hasNext ( ) ) ;
244258
245259 let newResultSet = await api . query ( "MATCH(n) return collect(n) as x" ) ;
260+ assert . equal ( newResultSet . size ( ) , 1 ) ;
246261 assert . ok ( newResultSet . hasNext ( ) ) ;
247262 var nodeA = new Node ( "person" , {
248263 name : "a" ,
249264 age : 32 ,
250- array : [ 0 , 1 , 2 ]
265+ array : [ 0 , 1 , 2 ] ,
251266 } ) ;
252267 nodeA . setId ( 0 ) ;
253268 var nodeB = new Node ( "person" , {
254269 name : "b" ,
255270 age : 30 ,
256- array : [ 3 , 4 , 5 ]
271+ array : [ 3 , 4 , 5 ] ,
257272 } ) ;
258273 nodeB . setId ( 1 ) ;
259274 assert . deepStrictEqual ( [ "x" ] , newResultSet . getHeader ( ) ) ;
@@ -269,6 +284,7 @@ describe("RedisGraphAPI Test", () => {
269284 }
270285 let values = await Promise . all ( promises ) ;
271286 for ( var resultSet of values ) {
287+ assert . equal ( resultSet . size ( ) , 1 ) ;
272288 let record = resultSet . next ( ) ;
273289 let n = record . get ( 0 ) ;
274290 assert . equal ( 34 , n . properties [ "age" ] ) ;
@@ -367,6 +383,7 @@ describe("RedisGraphAPI Test", () => {
367383 . build ( ) ;
368384
369385 let paths = new Set ( [ path01 , path12 , path02 ] ) ;
386+ assert . equal ( response . size ( ) , 3 ) ;
370387 while ( response . hasNext ( ) ) {
371388 let p = response . next ( ) . get ( "p" ) ;
372389 let pInPaths = false ;
@@ -394,7 +411,7 @@ describe("RedisGraphAPI Test", () => {
394411 "str" ,
395412 [ 1 , 2 , 3 ] ,
396413 [ "1" , "2" , "3" ] ,
397- null
414+ null ,
398415 ] ;
399416 let promises = [ ] ;
400417 for ( var i = 0 ; i < params . length ; i ++ ) {
0 commit comments