diff --git a/test/handlebars.js b/test/handlebars.js index 83d374cf..d514041f 100644 --- a/test/handlebars.js +++ b/test/handlebars.js @@ -2,6 +2,7 @@ module("basic context"); var shouldCompileTo = function(string, hash, result, message) { var template = Handlebars.compile(string); + console.log(template); var params = toString.call(hash) === "[object Array]" ? hash : [hash, undefined]; equal(template.apply(this, params), result, message); } @@ -193,6 +194,31 @@ test("nested block helpers", function() { equal(result, "
"); }); +test("block inverted sections", function() { + var string = "{{#list people}}{{name}}{{^}}Nobody's here{{/list}}" + var list = function(fn) { + if (this.length > 0) { + var out = "" + fn(this) + "
"; + }; + var hash = {list: list, people: [{name: "Alan"}, {name: "Yehuda"}]}; + + // the meaning here may be kind of hard to catch, but list.not is always called, + // so we should see the output of both + shouldCompileTo(string, hash, "Nobody's here
", "Not is called when block inverted section is encountered."); +}); + module("fallback hash"); test("providing a fallback hash", function() {