Browse Source

Refs #5121: Add test cases for depsToProjection

Chris Sexton 12 years ago
parent
commit
a4a5e96b56
1 changed files with 21 additions and 0 deletions
  1. 21 0
      test/lib/pipeline/documentSources/DocumentSource.js

+ 21 - 0
test/lib/pipeline/documentSources/DocumentSource.js

@@ -15,6 +15,27 @@ module.exports = {
 
 				assert.equal(expected, JSON.stringify(proj));
 			},
+			"should be able to convert dependencies with subfields to a projection": function(){
+				var array = {'a':1,'a.b':1},
+					expected = '{"_id":0,"a":1}',
+					proj = DocumentSource.depsToProjection(array);
+
+				assert.equal(expected, JSON.stringify(proj));
+			},
+			"should be able to convert dependencies with _id to a projection": function(){
+				var array = {"_id":1,'a':1,'b':1},
+					expected = '{"a":1,"b":1,"_id":1}',
+					proj = DocumentSource.depsToProjection(array);
+
+				assert.equal(expected, JSON.stringify(proj));
+			},
+			"should be able to convert dependencies with id and subfields to a projection": function(){
+				var array = {'_id.a':1,'b':1},
+					expected = '{"_id":1,"b":1}',
+					proj = DocumentSource.depsToProjection(array);
+
+				assert.equal(expected, JSON.stringify(proj));
+			},
 		}
 
 	}