aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/conversion/DocumentToHtmlTests.java17
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java6
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java24
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMapParserTests.java6
4 files changed, 52 insertions, 1 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/conversion/DocumentToHtmlTests.java b/src/test/java/org/zwobble/mammoth/tests/conversion/DocumentToHtmlTests.java
index ad85bbb..6155f5a 100644
--- a/src/test/java/org/zwobble/mammoth/tests/conversion/DocumentToHtmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/conversion/DocumentToHtmlTests.java
@@ -174,6 +174,23 @@ public class DocumentToHtmlTests {
}
@Test
+ public void smallCapsIsIgnoredByDefault() {
+ assertThat(
+ convertToHtml(run(withSmallCaps(true), withChildren(new Text("Hello")))),
+ deepEquals(list(Html.text("Hello"))));
+ }
+
+ @Test
+ public void smallCapsCanBeMappedUsingStyleMapping() {
+ assertThat(
+ convertToHtml(
+ run(withSmallCaps(true), withChildren(new Text("Hello"))),
+ StyleMap.builder().smallCaps(HtmlPath.element("span")).build()),
+
+ deepEquals(list(Html.element("span", list(Html.text("Hello"))))));
+ }
+
+ @Test
public void superscriptRunsAreWrappedInSuperscriptTags() {
assertThat(
convertToHtml(run(withVerticalAlignment(SUPERSCRIPT), withChildren(new Text("Hello")))),
diff --git a/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java b/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java
index ea53458..4bff04d 100644
--- a/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java
+++ b/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java
@@ -19,6 +19,7 @@ public class DocumentElementMakers {
private static final ArgumentKey<Boolean> ITALIC = new ArgumentKey<>("italic");
private static final ArgumentKey<Boolean> UNDERLINE = new ArgumentKey<>("underline");
private static final ArgumentKey<Boolean> STRIKETHROUGH = new ArgumentKey<>("strikethrough");
+ private static final ArgumentKey<Boolean> SMALL_CAPS = new ArgumentKey<>("smallCaps");
private static final ArgumentKey<VerticalAlignment> VERTICAL_ALIGNMENT = new ArgumentKey<>("verticalAlignment");
private static final ArgumentKey<List<DocumentElement>> CHILDREN = new ArgumentKey<>("children");
private static final ArgumentKey<Boolean> IS_HEADER = new ArgumentKey<>("isHeader");
@@ -53,6 +54,10 @@ public class DocumentElementMakers {
return arg(STRIKETHROUGH, strikethrough);
}
+ public static Argument<Boolean> withSmallCaps(boolean smallCaps) {
+ return arg(SMALL_CAPS, smallCaps);
+ }
+
public static Argument<VerticalAlignment> withVerticalAlignment(VerticalAlignment verticalAlignment) {
return arg(VERTICAL_ALIGNMENT, verticalAlignment);
}
@@ -106,6 +111,7 @@ public class DocumentElementMakers {
arguments.get(ITALIC, false),
arguments.get(UNDERLINE, false),
arguments.get(STRIKETHROUGH, false),
+ arguments.get(SMALL_CAPS, false),
arguments.get(VERTICAL_ALIGNMENT, VerticalAlignment.BASELINE),
arguments.get(STYLE, Optional.empty()),
arguments.get(CHILDREN, list())
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
index fc67a28..c5756ae 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
@@ -443,12 +443,34 @@ public class BodyXmlTests {
hasProperty("strikethrough", equalTo(true)));
}
+ @Test
+ public void runIsNotSmallCapsIfSmallCapsElementIsNotPresent() {
+ XmlElement element = runXmlWithProperties();
+
+ assertThat(
+ readSuccess(bodyReader(), element),
+ hasProperty("smallCaps", equalTo(false)));
+ }
+
+ @Test
+ public void runIsSmallCapsIfSmallCapsElementIsPresent() {
+ XmlElement element = runXmlWithProperties(element("w:smallCaps"));
+
+ assertThat(
+ readSuccess(bodyReader(), element),
+ hasProperty("smallCaps", equalTo(true)));
+ }
+
@RunWith(Parameterized.class)
public static class RunBooleanPropertyTests {
@Parameterized.Parameters(name = "propertyName: {0}, tagName: {1}")
public static Collection<Object[]> data() {
return list(new Object[][] {
- {"bold", "w:b"}, {"underline", "w:u"}, {"italic", "w:i"}, {"strikethrough", "w:strike"}
+ {"bold", "w:b"},
+ {"underline", "w:u"},
+ {"italic", "w:i"},
+ {"strikethrough", "w:strike"},
+ {"smallCaps", "w:smallCaps"}
});
}
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 89045a1..9837479 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
@@ -51,6 +51,12 @@ public class StyleMapParserTests {
}
@Test
+ public void canMapSmallCaps() {
+ StyleMap styleMap = StyleMapParser.parse("small-caps => span");
+ assertThat(styleMap, deepEquals(StyleMap.builder().smallCaps(HtmlPath.collapsibleElement("span")).build()));
+ }
+
+ @Test
public void canMapCommentReference() {
StyleMap styleMap = StyleMapParser.parse("comment-reference =>");
assertThat(styleMap, deepEquals(StyleMap.builder().commentReference(HtmlPath.EMPTY).build()));