From d5ea98799d381051d70e5810fbcdce8c0aeb05c0 Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Tue, 19 Nov 2013 16:19:17 -0800 Subject: [PATCH] Tests on $where --- packages/minimongo/minimongo_tests.js | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/minimongo/minimongo_tests.js b/packages/minimongo/minimongo_tests.js index a61269f230..19fb6a306f 100644 --- a/packages/minimongo/minimongo_tests.js +++ b/packages/minimongo/minimongo_tests.js @@ -2595,6 +2595,24 @@ Tinytest.add("minimongo - selector and projection combination", function (test) 'z': true }, "numbered keys in selector - incl"); + testSelProjectionComb({ + 'a.b.c': 42, + $where: function () { return true; } + }, { + 'a.b': 1, + 'z.z': 1 + }, {}, "$where in the selector - incl"); + + testSelProjectionComb({ + $or: [ + {'a.b.c': 42}, + {$where: function () { return true; } } + ] + }, { + 'a.b': 1, + 'z.z': 1 + }, {}, "$where in the selector - incl"); + // Test with exclusive projection testSelProjectionComb({ a: 1, b: 2 }, { b: 0, c: 0, d: 0 }, { c: false, d: false }, "simplest excl"); testSelProjectionComb({ $or: [{ a: 1234, e: {$lt: 5} }], b: 2 }, { b: 0, c: 0, d: 0 }, { c: false, d: false }, "simplest excl, branching"); @@ -2699,5 +2717,23 @@ Tinytest.add("minimongo - selector and projection combination", function (test) 'x.x': false, }, "numbered keys in selector - excl"); + testSelProjectionComb({ + 'a.b.c': 42, + $where: function () { return true; } + }, { + 'a.b': 0, + 'z.z': 0 + }, {}, "$where in the selector - excl"); + + testSelProjectionComb({ + $or: [ + {'a.b.c': 42}, + {$where: function () { return true; } } + ] + }, { + 'a.b': 0, + 'z.z': 0 + }, {}, "$where in the selector - excl"); + });