From 764ceb6077d7aa76f11868beb9134522263fda8a Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 28 Jan 2014 17:00:00 -0800 Subject: [PATCH] add a test for observeChanges/limit/initial --- packages/minimongo/minimongo_tests.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/minimongo/minimongo_tests.js b/packages/minimongo/minimongo_tests.js index 3ace1c931e..4bb58d2b94 100644 --- a/packages/minimongo/minimongo_tests.js +++ b/packages/minimongo/minimongo_tests.js @@ -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({});