From e71027cb230d82653fa4684b2d1dfcac55f69b4d Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 5 Mar 2014 12:33:48 -0800 Subject: [PATCH] more _generateKeysFromDoc unit tests --- packages/minimongo/minimongo_tests.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/minimongo/minimongo_tests.js b/packages/minimongo/minimongo_tests.js index fe004e7843..0f759afabf 100644 --- a/packages/minimongo/minimongo_tests.js +++ b/packages/minimongo/minimongo_tests.js @@ -1811,12 +1811,26 @@ Tinytest.add("minimongo - sort keys", function (test) { test.equal(actualKeys, expectedKeys); }; + // Just non-array fields. + testKeys({'a.x': 1, 'a.y': 1}, + {a: {x: 0, y: 5}}, + [[0,5]]); + + // Ensure that we don't get [0,3] and [1,5]. testKeys({'a.x': 1, 'a.y': 1}, {a: [{x: 0, y: 5}, {x: 1, y: 3}]}, [[0,5], [1,3]]); + + // Ensure we can combine "array fields" with "non-array fields". testKeys({'a.x': 1, 'a.y': 1, b: -1}, {a: [{x: 0, y: 5}, {x: 1, y: 3}], b: 42}, [[0,5,42], [1,3,42]]); + testKeys({b: -1, 'a.x': 1, 'a.y': 1}, + {a: [{x: 0, y: 5}, {x: 1, y: 3}], b: 42}, + [[42,0,5], [42,1,3]]); + testKeys({'a.x': 1, b: -1, 'a.y': 1}, + {a: [{x: 0, y: 5}, {x: 1, y: 3}], b: 42}, + [[0,42,5], [1,42,3]]); }); Tinytest.add("minimongo - binary search", function (test) {