Permalink
Browse files

Test iterate limit and concurrent

  • Loading branch information...
1 parent 72dc6c6 commit 21c114f3ba1ffad98fb8f3f64d13d821c1921672 @1602 committed Jan 10, 2014
Showing with 23 additions and 0 deletions.
  1. +23 −0 test/manipulation.test.js
View
@@ -272,6 +272,29 @@ describe('manipulation', function() {
done();
});
});
+
+ it('should take limit into account', function(done) {
+ var num = 0;
+ Person.iterate({batchSize: 20, limit: 21}, function(person, next, i) {
+ num += 1;
+ next();
+ }, function(err) {
+ num.should.equal(21);
+ done();
+ });
+ });
+
+ it('should process in concurrent mode', function(done) {
+ var num = 0, time = Date.now();
+ Person.iterate({batchSize: 10, limit: 21, concurrent: true}, function(person, next, i) {
+ num += 1;
+ setTimeout(next, 20);
+ }, function(err) {
+ num.should.equal(21);
+ should.ok(Date.now() - time < 100, 'should work in less than 100ms');
+ done();
+ });
+ });
});
describe('initialize', function() {

0 comments on commit 21c114f

Please sign in to comment.