|
@@ -89,13 +89,17 @@ module.exports = {
|
|
|
assert.deepEqual(a, e, "Unexpected value (not deepEqual)!");
|
|
|
assert.equal(JSON.stringify(munger(i)), JSON.stringify(e), "Reuse of munger should yield the same results!");
|
|
|
assert.equal(JSON.stringify(munge(p, i)), JSON.stringify(e), "Alternate use of munge should yield the same results!");
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
-/*
|
|
|
"should be able to use a $project operator": function(){
|
|
|
- var i = [{_id:0, e:1}, {_id:1, e:0}, {_id:2, e:1}, {_id:3, e:0}, {_id:4, e:1}, {_id:5, e:0}],
|
|
|
- p = [{$project:{e:1}}],
|
|
|
- e = [{_id:0, e:1}, {_id:2, e:1}, {_id:4, e:1}],
|
|
|
+ var i = [{_id:0, e:1, f:23}, {_id:2, e:2, g:34}, {_id:4, e:3}],
|
|
|
+ p = [{$project:{
|
|
|
+ e:1,
|
|
|
+ a:{$add:["$e", "$e"]},
|
|
|
+ b:{$cond:[{$eq:["$e", 2]}, "two", "not two"]}
|
|
|
+ }}],
|
|
|
+ e = [{_id:0, e:1, b:"not two", a:2}, {_id:2, e:2, b:"two", a:4}, {_id:4, e:3, b:"not two", a:6}],
|
|
|
munger = munge(p),
|
|
|
a = munger(i);
|
|
|
assert.equal(JSON.stringify(a), JSON.stringify(e), "Unexpected value!");
|
|
@@ -104,31 +108,25 @@ module.exports = {
|
|
|
assert.equal(JSON.stringify(munge(p, i)), JSON.stringify(e), "Alternate use of munge should yield the same results!");
|
|
|
},
|
|
|
|
|
|
-//TODO: $project w/ expressions
|
|
|
-
|
|
|
-
|
|
|
"should be able to construct an instance with $sort operators properly (ascending)": function(){
|
|
|
var i = [
|
|
|
{_id:3.14159}, {_id:-273.15},
|
|
|
{_id:42}, {_id:11}, {_id:1},
|
|
|
- {_id:false},{_id:true},
|
|
|
- {_id:""}, {_id:"a"}, {_id:"A"}, {_id:"Z"}, {_id:"z"},
|
|
|
- {_id:null}, {_id:NaN},
|
|
|
- //TODO: test with Objects; e.g., {_id:{a:{b:1}},
|
|
|
- {_id:new Date("2012-10-22T08:01:21.235Z")}, {_id:new Date("2012-10-15T15:48:55.181Z")}
|
|
|
+ {_id:null}, {_id:NaN}
|
|
|
],
|
|
|
p = [{$sort:{_id:1}}],
|
|
|
e = [
|
|
|
{_id:null}, {_id:NaN},
|
|
|
- {_id:-273.15}, {_id:1}, {_id:3.14159}, {_id:11}, {_id:42},
|
|
|
- {_id:""}, {_id:"A"}, {_id:"Z"}, {_id:"a"}, {_id:"z"},
|
|
|
- {_id:false}, {_id:true},
|
|
|
- {_id:new Date("2012-10-15T15:48:55.181Z")}, {_id:new Date("2012-10-22T08:01:21.235Z")}
|
|
|
- ];
|
|
|
- var a = munge(p, i);
|
|
|
+ {_id:-273.15}, {_id:1}, {_id:3.14159}, {_id:11}, {_id:42}
|
|
|
+ ],
|
|
|
+ munger = munge(p),
|
|
|
+ a = munger(i);
|
|
|
assert.equal(JSON.stringify(a), JSON.stringify(e), "Unexpected value!");
|
|
|
+ //assert.deepEqual(a, e); //does not work with NaN
|
|
|
+ assert.equal(JSON.stringify(munger(i)), JSON.stringify(e), "Reuse of munger should yield the same results!");
|
|
|
+ assert.equal(JSON.stringify(munge(p, i)), JSON.stringify(e), "Alternate use of munge should yield the same results!");
|
|
|
}
|
|
|
-*/
|
|
|
+
|
|
|
}
|
|
|
|
|
|
};
|