@@ -9,7 +9,7 @@ const ARANGO_VERSION = Number(
99 process . env . ARANGO_VERSION || process . env . ARANGOJS_DEVEL_VERSION || 30400
1010) ;
1111
12- const aqlQuery = aql `FOR i In 0..10 RETURN i` ;
12+ const aqlQuery = aql `FOR i IN 0..10 RETURN i` ;
1313const aqlResult = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
1414
1515async function sleep ( ms : number ) {
@@ -73,7 +73,7 @@ describe("Item-wise Cursor API", () => {
7373 expect ( cursor . hasNext ) . to . equal ( true ) ;
7474 } ) ;
7575 it ( "returns false after last batch is consumed" , async ( ) => {
76- const cursor = await db . query ( aql `FOR i In 0..1 RETURN i` , {
76+ const cursor = await db . query ( aql `FOR i IN 0..1 RETURN i` , {
7777 batchSize : 2 ,
7878 } ) ;
7979 expect ( cursor . hasNext ) . to . equal ( true ) ;
@@ -88,7 +88,7 @@ describe("Item-wise Cursor API", () => {
8888 expect ( ( cursor . batches as any ) . _batches . length ) . to . equal ( 0 ) ;
8989 } ) ;
9090 it ( "returns false after last result is consumed" , async ( ) => {
91- const cursor = await db . query ( aql `FOR i In 0..1 RETURN i` , {
91+ const cursor = await db . query ( aql `FOR i IN 0..1 RETURN i` , {
9292 batchSize : 2 ,
9393 } ) ;
9494 expect ( cursor . hasNext ) . to . equal ( true ) ;
@@ -103,7 +103,7 @@ describe("Item-wise Cursor API", () => {
103103 expect ( ( cursor . batches as any ) . _batches . length ) . to . equal ( 0 ) ;
104104 } ) ;
105105 it . skip ( "returns 404 after timeout" , async ( ) => {
106- const cursor = await db . query ( aql `FOR i In 0..1 RETURN i` , {
106+ const cursor = await db . query ( aql `FOR i IN 0..1 RETURN i` , {
107107 batchSize : 1 ,
108108 ttl : 1 ,
109109 } ) ;
@@ -132,9 +132,14 @@ describe("Item-wise Cursor API", () => {
132132 await loadMore ( cursor , totalLength ) ;
133133 }
134134 }
135- const cursor = await db . query ( `FOR i In 1..${ EXPECTED_LENGTH } RETURN i` ) ;
135+ const cursor = await db . query ( `FOR i IN 1..${ EXPECTED_LENGTH } RETURN i` ) ;
136136 await loadMore ( cursor , 0 ) ;
137137 } ) ;
138+ it ( "returns false if there are no results" , async ( ) => {
139+ const cursor = await db . query ( aql `FOR i IN [] RETURN i` ) ;
140+ expect ( cursor . hasNext ) . to . equal ( false ) ;
141+ expect ( ( cursor . batches as any ) . _batches . length ) . to . equal ( 0 ) ;
142+ } ) ;
138143 } ) ;
139144 describe ( "cursor.forEach" , ( ) => {
140145 it ( "invokes the callback for each value" , async ( ) => {
@@ -144,6 +149,14 @@ describe("Item-wise Cursor API", () => {
144149 } ) ;
145150 expect ( results ) . to . eql ( aqlResult ) ;
146151 } ) ;
152+ it ( "correctly handles empty results" , async ( ) => {
153+ const cursor = await db . query ( aql `FOR i IN [] RETURN i` ) ;
154+ const results : any [ ] = [ ] ;
155+ await cursor . forEach ( ( value ) => {
156+ results . push ( value ) ;
157+ } ) ;
158+ expect ( results ) . to . eql ( [ ] ) ;
159+ } ) ;
147160 it ( "aborts if the callback returns false" , async ( ) => {
148161 const results : any [ ] = [ ] ;
149162 await cursor . forEach ( ( value ) => {
@@ -264,7 +277,7 @@ describe("Batch-wise Cursor API", () => {
264277 } ) ;
265278 it ( "returns false after last batch is consumed" , async ( ) => {
266279 const cursor = (
267- await db . query ( aql `FOR i In 0..1 RETURN i` , {
280+ await db . query ( aql `FOR i IN 0..1 RETURN i` , {
268281 batchSize : 1 ,
269282 } )
270283 ) . batches ;
@@ -280,7 +293,7 @@ describe("Batch-wise Cursor API", () => {
280293 expect ( ( cursor as any ) . _batches . length ) . to . equal ( 0 ) ;
281294 } ) ;
282295 it . skip ( "returns 404 after timeout" , async ( ) => {
283- const cursor = await db . query ( aql `FOR i In 0..1 RETURN i` , {
296+ const cursor = await db . query ( aql `FOR i IN 0..1 RETURN i` , {
284297 batchSize : 1 ,
285298 ttl : 1 ,
286299 } ) ;
@@ -309,7 +322,7 @@ describe("Batch-wise Cursor API", () => {
309322 await loadMore ( cursor , totalLength ) ;
310323 }
311324 }
312- const cursor = await db . query ( `FOR i In 1..${ EXPECTED_LENGTH } RETURN i` ) ;
325+ const cursor = await db . query ( `FOR i IN 1..${ EXPECTED_LENGTH } RETURN i` ) ;
313326 await loadMore ( cursor , 0 ) ;
314327 } ) ;
315328 } ) ;
0 commit comments