Skip to content

Commit

Permalink
update tests for nested shortcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorsten Marx committed Dec 9, 2024
1 parent 8e35cd5 commit 53c494b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ void setup() {
return "message: " + params.get("message");
});

tagMap.put("parent", params -> {
return "<div class='parent'>%s</div>".formatted((String)params.get("_content"));
});
tagMap.put("nested", params -> {
return "nested";
});

this.tagParser = new TagParser(new JexlBuilder().create());
}

Expand Down Expand Up @@ -154,20 +161,20 @@ public void multiline () {

String result = tagParser.parse(content, tagMap);

System.out.println("-" + result + "-");
Assertions.assertThat(result).isEqualToIgnoringWhitespace("This is a multiline shortcode!");
}

@Test
public void nested () {
String content = """
[[content]]
[[parent]]
[[nested /]]
[[/content]]
[[/parent]]
""";

var tags = tagParser.findTags(content, tagMap);
Assertions.assertThat(tags.size()).isEqualTo(1);
String result = tagParser.parse(content, tagMap);
System.out.println("-" + result + "-");
Assertions.assertThat(result).isEqualToIgnoringWhitespace("<div class='parent'>nested</div>");
}
}

0 comments on commit 53c494b

Please sign in to comment.