From b38579fd13826ac6e5fc210f1d71d37c33f4df5a Mon Sep 17 00:00:00 2001 From: Naomi Seyfer Date: Fri, 8 Mar 2013 17:24:03 -0800 Subject: [PATCH] more testing to make sure factories happen in observes --- packages/mongo-livedata/mongo_livedata_tests.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/mongo-livedata/mongo_livedata_tests.js b/packages/mongo-livedata/mongo_livedata_tests.js index a481bd2e1f..289cdcc928 100644 --- a/packages/mongo-livedata/mongo_livedata_tests.js +++ b/packages/mongo-livedata/mongo_livedata_tests.js @@ -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({}); })); } ]);