Skip to content

Commit

Permalink
More Model.aggregate() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Joyard committed Mar 28, 2013
1 parent 7e3a843 commit 19ce303
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions test/model.aggregate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var start = require('./common')
, assert = require('assert')
, random = require('../lib/utils').random
, Query = require('../lib/query')
, Aggregate = require('../lib/aggregate')
, Schema = mongoose.Schema
, SchemaType = mongoose.SchemaType
, ObjectId = Schema.Types.ObjectId
Expand Down Expand Up @@ -67,7 +68,8 @@ describe('model aggregate', function(){
assert.equal(maxAge, res[0].maxAge);
done();
});
})
});

it('with arrays', function(done){
this.timeout(4000);

Expand All @@ -79,6 +81,28 @@ describe('model aggregate', function(){
assert.equal(maxAge, res[0].maxAge);
done();
});
})
});

it('with Aggregate syntax', function(done) {
this.timeout(4000);

A.aggregate()
.group(group.$group)
.project(project.$project)
.exec(function (err, res) {
assert.ifError(err);
assert.ok(res);
assert.equal(1, res.length);
assert.ok('maxAge' in res[0]);
assert.equal(maxAge, res[0].maxAge);
done();
});
});

it('when returning Aggregate', function(done) {
assert(A.aggregate(group) instanceof Aggregate);

done();
});
})
});

0 comments on commit 19ce303

Please sign in to comment.