more testing to make sure factories happen in observes

This commit is contained in:
Naomi Seyfer
2013-03-08 17:24:03 -08:00
parent 996fc144bf
commit b38579fd13

View File

@@ -648,13 +648,29 @@ testAsyncMulti('mongo-livedata - document goes through a factory, ' + idGenerati
var coll = new Meteor.Collection(collectionName, collectionOptions);
var docId;
var expectAdd = expect(function (doc) {
test.equal(doc.seconds(), 50);
});
var expectRemove = expect (function (doc) {
test.equal(doc.seconds(), 50);
});
coll.insert({d: new Date(1356152390004)}, expect(function (err, id) {
test.isFalse(err);
test.isTrue(id);
docId = id;
var cursor = coll.find();
cursor.observe({
added: expectAdd,
removed: expectRemove
});
test.equal(cursor.count(), 1);
test.equal(cursor.fetch()[0].seconds(), 50);
test.equal(coll.findOne().seconds(), 50);
test.equal(coll.findOne({}, {factory: null}).seconds, undefined);
test.equal(coll.findOne({}, {
factory: function (doc) {return {seconds: doc.d.getSeconds()};}
}).seconds, 50);
coll.remove({});
}));
}
]);