From a26168d0c52aeec2dfbe6fffc1531219b4dcd199 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 13 Jun 2024 12:40:05 +0100 Subject: Parse highlight matchers --- .../parsing/DocumentMatcherParsingTests.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/test/java/org/zwobble') diff --git a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java index 1af4a86..7c39e78 100644 --- a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java @@ -8,6 +8,8 @@ import org.zwobble.mammoth.internal.styles.parsing.StyleMappingTokeniser; import org.zwobble.mammoth.internal.styles.parsing.TokenIterator; import org.zwobble.mammoth.internal.styles.parsing.TokenType; +import java.util.Optional; + import static org.hamcrest.MatcherAssert.assertThat; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; @@ -147,6 +149,30 @@ public class DocumentMatcherParsingTests { ); } + @Test + public void readsHighlightWithoutColor() { + assertThat( + parseDocumentMatcher("highlight"), + deepEquals( + new StyleMapBuilder() + .mapHighlight(new HighlightMatcher(Optional.empty()), HTML_PATH) + .build() + ) + ); + } + + @Test + public void readsHighlightWithColor() { + assertThat( + parseDocumentMatcher("highlight[color='yellow']"), + deepEquals( + new StyleMapBuilder() + .mapHighlight(new HighlightMatcher(Optional.of("yellow")), HTML_PATH) + .build() + ) + ); + } + private static final HtmlPath HTML_PATH = HtmlPath.element("placeholder"); private StyleMap parseDocumentMatcher(String input) { -- cgit v1.2.3