Explorar o código

Refs #5122: Change test case to use async

Chris Sexton %!s(int64=12) %!d(string=hai) anos
pai
achega
273a97ea27
Modificáronse 1 ficheiros con 13 adicións e 16 borrados
  1. 13 16
      test/lib/pipeline/documentSources/CursorDocumentSource.js

+ 13 - 16
test/lib/pipeline/documentSources/CursorDocumentSource.js

@@ -63,26 +63,23 @@ module.exports = {
 				assert.equal(cds.getNext(), DocumentSource.EOF);
 			},
 			"should return the current cursor value async": function(next){
+				var expected = JSON.stringify([1,2]);
 				var cwc = new CursorDocumentSource.CursorWithContext();
 				cwc._cursor = new Cursor( [1,2,3,4] );
 
 				var cds = new CursorDocumentSource(cwc);
-				cds.getNext(function(err,val) {
-					assert.equal(val, 1);
-					cds.getNext(function(err,val) {
-						assert.equal(val, 2);
-						cds.getNext(function(err,val) {
-							assert.equal(val, 3);
-							cds.getNext(function(err,val) {
-								assert.equal(val, 4);
-								cds.getNext(function(err,val) {
-									assert.equal(val, DocumentSource.EOF);
-									next();
-								});
-							});
-						});
-					});
-				});
+				async.series([
+						cds.getNext.bind(cds),
+						cds.getNext.bind(cds),
+						cds.getNext.bind(cds),
+						cds.getNext.bind(cds),
+						cds.getNext.bind(cds),
+					],
+					function(err,res) {
+						assert.deepEqual([1,2,3,4,DocumentSource.EOF], res);
+						next();
+					}
+				);
 			},
 			"should return values past the batch limit": function(){
 				var cwc = new CursorDocumentSource.CursorWithContext(),