Просмотр исходного кода

EAGLESIX-2712: Add test case file MapExpression_test.js

Jason Walton 11 лет назад
Родитель
Сommit
5d99b3b380

+ 2 - 3
lib/pipeline/expressions/MapExpression.js

@@ -14,14 +14,13 @@ var Variables = require("./Variables"),
 
 // PROTOTYPE MEMBERS
 
-
 klass.parse = function parse(expr, vpsIn){
 	if(!("$map" in expr)) {
 		throw new Error("Tried to create a $let with something other than let. Looks like your parse map went all funny.");
 	}
 
 	if(typeof(expr.$map) !== 'object' || (expr.$map instanceof Array)) {
-		throw new Error("$map only supports an object as it's argument:16878");
+		throw new Error("$map only supports an object as its argument:16878");
 	}
 
 	var args = expr.$map,
@@ -36,7 +35,7 @@ klass.parse = function parse(expr, vpsIn){
 		throw new Error("Missing 'as' parameter to $map: 16881");
 	}
 	if(!inElem) {
-		throw new Error("Missing 'in' parameter to $let: 16882");
+		throw new Error("Missing 'in' parameter to $map: 16882");
 	}
 
 

+ 18 - 6
test/lib/pipeline/expressions/MapExpression_test.js

@@ -1,6 +1,7 @@
 "use strict";
 var assert = require("assert"),
 	MapExpression = require("../../../../lib/pipeline/expressions/MapExpression"),
+	DepsTracker = require("../../../../lib/pipeline/DepsTracker"),
 	Expression = require("../../../../lib/pipeline/expressions/Expression");
 
 // Mocha one-liner to make these tests self-hosted
@@ -17,11 +18,22 @@ module.exports = {
 			},
 
 			"should not accept less than 4 arguments": function () {
-				assert.throws(function () {new MapExpression()});
-				assert.throws(function () {new MapExpression(1)});
-				assert.throws(function () {new MapExpression(1, 2)});
-				assert.throws(function () {new MapExpression(1, 2, 3)});
-			}
+				assert.throws(function () { new MapExpression(); });
+				assert.throws(function () { new MapExpression(1); });
+				assert.throws(function () { new MapExpression(1, 2); });
+				assert.throws(function () { new MapExpression(1, 2, 3); });
+			},
+		},
+
+		"optimize": {
+			"trivial case": function() {
+				var m = new MapExpression("test", "varname", new Expression(), new Expression());
+				assert.ok(m.optimize());
+			},
+		},
+
+		"addDependencies": {
+			"trivial case - calls addDependencies on _input and _each": function () {}
 		}
 	}
-}
+};