-
Notifications
You must be signed in to change notification settings - Fork 31
/
test.js
42 lines (33 loc) · 1.1 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Tinytest.add('method signature', function(test) {
var coll = new Mongo.Collection(Random.id());
test.equal(typeof coll.aggregate, 'function');
});
Tinytest.add("let's aggregate", function(test) {
var coll = new Mongo.Collection(Random.id());
coll.insert({resTime: 20});
coll.insert({resTime: 40});
var result = coll.aggregate([
{$group: {_id: null, resTime: {$sum: "$resTime"}}}
]);
test.equal(result, [{_id: null, resTime: 60}]);
});
Tinytest.add("aggregate on Meteor.users", function(test) {
var coll = Meteor.users;
coll.remove({});
coll.insert({resTime: 20});
coll.insert({resTime: 40});
var result = coll.aggregate([
{$group: {_id: null, resTime: {$sum: "$resTime"}}}
]);
test.equal(result, [{_id: null, resTime: 60}]);
});
Tinytest.add("using some options", function(test) {
var coll = new Mongo.Collection(Random.id());
coll.insert({resTime: 20});
coll.insert({resTime: 40});
var options = {explain: true};
var result = coll.aggregate([
{$group: {_id: null, resTime: {$sum: "$resTime"}}}
], options);
test.equal(typeof result[0]['$cursor'], 'object');
});