summaryrefslogtreecommitdiffstats
path: root/spec/qunit_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/qunit_spec.js')
-rw-r--r--spec/qunit_spec.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js
index 6a093f3..31c9b96 100644
--- a/spec/qunit_spec.js
+++ b/spec/qunit_spec.js
@@ -797,6 +797,10 @@ test("with", function() {
var string = "{{#with person}}{{first}} {{last}}{{/with}}";
shouldCompileTo(string, {person: {first: "Alan", last: "Johnson"}}, "Alan Johnson");
});
+test("with with function argument", function() {
+ var string = "{{#with person}}{{first}} {{last}}{{/with}}";
+ shouldCompileTo(string, {person: function() { return {first: "Alan", last: "Johnson"};}}, "Alan Johnson");
+});
test("if", function() {
var string = "{{#if goodbye}}GOODBYE {{/if}}cruel {{world}}!";
@@ -861,6 +865,15 @@ test("each with @index", function() {
equal(result, "0. goodbye! 1. Goodbye! 2. GOODBYE! cruel world!", "The @index variable is used");
});
+test("each with function argument", function() {
+ var string = "{{#each goodbyes}}{{text}}! {{/each}}cruel {{world}}!";
+ var hash = {goodbyes: function () { return [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}];}, world: "world"};
+ shouldCompileTo(string, hash, "goodbye! Goodbye! GOODBYE! cruel world!",
+ "each with array function argument iterates over the contents when not empty");
+ shouldCompileTo(string, {goodbyes: [], world: "world"}, "cruel world!",
+ "each with array function argument ignores the contents when empty");
+});
+
test("data passed to helpers", function() {
var string = "{{#each letters}}{{this}}{{detectDataInsideEach}}{{/each}}";
var hash = {letters: ['a', 'b', 'c']};