Test that names are being processed in partials; fixed exception on attempt to

use partials when unconfigured; moved partials tests down into a more sensible
location among the tests.
This commit is contained in:
Michael Bayne
2011-04-13 14:42:30 -07:00
parent 419a8b887c
commit a0bc4dc3b6
@@ -21,20 +21,6 @@ import org.junit.Test;
*/
public class MustacheTest
{
@Test(expected = IllegalArgumentException.class)
public void testDefaultTemplateIncludeBehavior () {
test(null, "{{>foo}}", null);
}
@Test
public void testTemplateIncludeBehavior () {
test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
return new StringReader("inside:{{bar}}");
}
}), "foo inside:foo foo", "{{bar}} {{>foo}} {{bar}}", context("bar", "foo"));
}
@Test public void testSimpleVariable () {
test("bar", "{{foo}}", context("foo", "bar"));
}
@@ -131,6 +117,23 @@ public class MustacheTest
test("foobar", "foo{{! nothing to see here}}bar", new Object());
}
@Test(expected=UnsupportedOperationException.class)
public void testPartialUseWhenUnconfigured () {
test(null, "{{>foo}}", null);
}
@Test public void testPartial () {
test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
if (name.equals("foo")) {
return new StringReader("inside:{{bar}}");
} else {
return new StringReader("nonfoo");
}
}
}), "foo inside:foo nonfoo foo", "{{bar}} {{>foo}} {{>baz}} {{bar}}", context("bar", "foo"));
}
@Test public void testUnescapeHTML () {
assertEquals("<b>", Mustache.compiler().escapeHTML(true).compile("{{&a}}").
execute(context("a", "<b>")));