From 329ecde4ea750c9e68ca49eb0f7b42dd9ae36063 Mon Sep 17 00:00:00 2001 From: vybs Date: Tue, 2 Oct 2012 11:27:20 -0700 Subject: [PATCH] Add unit tests for lt helper with variables --- test/jasmine-test/spec/helpersTests.js | 57 ++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/test/jasmine-test/spec/helpersTests.js b/test/jasmine-test/spec/helpersTests.js index 87d327f..e79fd71 100644 --- a/test/jasmine-test/spec/helpersTests.js +++ b/test/jasmine-test/spec/helpersTests.js @@ -547,11 +547,60 @@ var helpersTests = [ message: "lt helper with no body silently fails with console log" }, { - name: "lt helper with type number", - source: "{@lt key=\"2\" value=\"3\" type=\"number\"}2 less than 3{/lt}", + name: "lt helper defaults to type number", + source: "{@lt key=\"22\" value=\"33\"}22 less than 33{/lt}", context: {}, - expected: "2 less than 3", - message: "lt helper with type number" + expected: "22 less than 33", + message: "lt helper will default to type number" + }, + { + name: "lt helper with a variable with explicit type number", + source: "{@lt key=\"{a}\" value=\"33\" type=\"number\"}22 less than 33{/lt}", + context: {a:22}, + expected: "22 less than 33", + message: "lt helper with a variable with explicit type number" + }, + { + name: "lt helper with a variable defaults to type number ( type is not mandatory)", + source: "{@lt key=\"{a}\" value=\"33\"}22 less than 33{/lt}", + context: {a:22}, + expected: "22 less than 33", + message: "lt helper with a variable will default to type number" + }, + { + name: "lt helper with a variable defaults to type number", + source: "{@lt key=a value=\"33\"}22 less than 33{/lt}", + context: {a:22}, + expected: "22 less than 33", + message: "lt helper with a variable will default to type number" + }, + { + name: "lt helper with a variable type returned as string from tap", + source: "{@lt key=\"{a}\" value=\"3\"}22 less than 3, since it is string compare{/lt}", + context: {a:22}, + expected: "22 less than 3, since it is string compare", + message: "lt helper with a variable type returned as string from tap" + }, + { + name: "lt helper with a variable type returned as int from tap", + source: "{@lt key=a value=\"3\"}22 less than 3{/lt}", + context: {a:22}, + expected: "", + message: "lt helper with a with a variable type returned as int from tap" + }, + { + name: "lt helper with a variable with type string representing int", + source: "{@lt key=a value=\"33\"}22 less than 33{/lt}", + context: {a:"22"}, + expected: "22 less than 33", + message: "lt helper with a variable with type string representing int" + }, + { + name: "lt helper with a variable with type string representing float", + source: "{@lt key=a value=\"33\"}22 less than 33{/lt}", + context: {a:"22.33"}, + expected: "22 less than 33", + message: "lt helper with a variable with type string representing float" }, { name: "gt helper with type string not valid case",