From b6eabe382e59235192691b5bf04a172ce333ec24 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 28 Nov 2016 16:34:20 +0000 Subject: Add parsing for break style mappings --- .../tests/styles/parsing/StyleMapParserTests.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMapParserTests.java b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMapParserTests.java index d6205cd..5456cb8 100644 --- a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMapParserTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMapParserTests.java @@ -1,10 +1,7 @@ package org.zwobble.mammoth.tests.styles.parsing; import org.junit.Test; -import org.zwobble.mammoth.internal.styles.HtmlPath; -import org.zwobble.mammoth.internal.styles.ParagraphMatcher; -import org.zwobble.mammoth.internal.styles.RunMatcher; -import org.zwobble.mammoth.internal.styles.StyleMap; +import org.zwobble.mammoth.internal.styles.*; import org.zwobble.mammoth.internal.styles.parsing.StyleMapParser; import static org.hamcrest.MatcherAssert.assertThat; @@ -59,6 +56,24 @@ public class StyleMapParserTests { assertThat(styleMap, deepEquals(StyleMap.builder().commentReference(HtmlPath.EMPTY).build())); } + @Test + public void canMapLineBreaks() { + StyleMap styleMap = StyleMapParser.parse("br[type='line'] => div"); + StyleMap expectedStyleMap = StyleMap.builder() + .mapBreak(BreakMatcher.LINE_BREAK, HtmlPath.collapsibleElement("div")) + .build(); + assertThat(styleMap, deepEquals(expectedStyleMap)); + } + + @Test + public void canMapPageBreaks() { + StyleMap styleMap = StyleMapParser.parse("br[type='page'] => div"); + StyleMap expectedStyleMap = StyleMap.builder() + .mapBreak(BreakMatcher.PAGE_BREAK, HtmlPath.collapsibleElement("div")) + .build(); + assertThat(styleMap, deepEquals(expectedStyleMap)); + } + @Test public void blankLinesAreIgnored() { StyleMap styleMap = StyleMapParser.parse("\n\n \n\np =>\n\r\n"); -- cgit v1.2.3