From a506a6d3679c282cfd3a2f0257f5859d420feb22 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 20 Feb 2016 15:02:54 +0000 Subject: Allow paragraph matchers by style name --- .../mammoth/tests/DocumentConverterTests.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java index 771431f..338776e 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java @@ -6,6 +6,7 @@ import org.zwobble.mammoth.documents.*; import org.zwobble.mammoth.html.Html; import org.zwobble.mammoth.html.HtmlNode; import org.zwobble.mammoth.styles.HtmlPath; +import org.zwobble.mammoth.styles.ParagraphMatcher; import org.zwobble.mammoth.styles.StyleMap; import java.io.ByteArrayInputStream; @@ -56,7 +57,25 @@ public class DocumentConverterTests { assertThat( convertToHtml( make(a(PARAGRAPH, with(STYLE, Optional.of(new Style("TipsParagraph", Optional.empty()))))), - StyleMap.builder().mapParagraph("TipsParagraph", HtmlPath.element("p", map("class", "tip"))).build()), + StyleMap.builder() + .mapParagraph( + ParagraphMatcher.styleId("TipsParagraph"), + HtmlPath.element("p", map("class", "tip"))) + .build()), + + deepEquals(list(Html.element("p", map("class", "tip"))))); + } + + @Test + public void styleMappingsUsingStyleNamesCanBeUsedToMapParagraphs() { + assertThat( + convertToHtml( + make(a(PARAGRAPH, with(STYLE, Optional.of(new Style("TipsParagraph", Optional.of("Tips Paragraph")))))), + StyleMap.builder() + .mapParagraph( + ParagraphMatcher.styleName("Tips Paragraph"), + HtmlPath.element("p", map("class", "tip"))) + .build()), deepEquals(list(Html.element("p", map("class", "tip"))))); } -- cgit v1.2.3