add a test for observeChanges/limit/initial

This commit is contained in:
David Glasser
2014-01-28 17:00:00 -08:00
parent 25fd3a344c
commit 764ceb6077

View File

@@ -2170,7 +2170,8 @@ Tinytest.add("minimongo - observe ordered", function (test) {
handle.stop();
// test _suppress_initial
handle = c.find({}, {sort: {a: -1}}).observe(_.extend(cbs, {_suppress_initial: true}));
handle = c.find({}, {sort: {a: -1}}).observe(_.extend({
_suppress_initial: true}, cbs));
test.equal(operations.shift(), undefined);
c.insert({a:100});
test.equal(operations.shift(), ['added', {a:100}, 0, idA2]);
@@ -2197,6 +2198,21 @@ Tinytest.add("minimongo - observe ordered", function (test) {
test.equal(operations.shift(), ['changed', {a:3.5}, 0, {a:3}]);
handle.stop();
// test observe limit with pre-existing docs
c.remove({});
c.insert({a: 1});
c.insert({_id: 'two', a: 2});
c.insert({a: 3});
handle = c.find({}, {sort: {a: 1}, limit: 2}).observe(cbs);
test.equal(operations.shift(), ['added', {a:1}, 0, null]);
test.equal(operations.shift(), ['added', {a:2}, 1, null]);
test.equal(operations.shift(), undefined);
c.remove({a: 2});
test.equal(operations.shift(), ['removed', 'two', 1, {a:2}]);
test.equal(operations.shift(), ['added', {a:3}, 1, null]);
test.equal(operations.shift(), undefined);
handle.stop();
// test _no_indices
c.remove({});