diff options
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 23 |
1 files changed, 18 insertions, 5 deletions
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 49d906f..86b58f6 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -4,11 +4,11 @@ import com.natpryce.makeiteasy.Maker; import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.Test; -import org.zwobble.mammoth.results.Result; import org.zwobble.mammoth.documents.*; import org.zwobble.mammoth.docx.BodyXmlReader; import org.zwobble.mammoth.docx.Numbering; import org.zwobble.mammoth.docx.Styles; +import org.zwobble.mammoth.results.Result; import org.zwobble.mammoth.results.Warning; import org.zwobble.mammoth.tests.DeepReflectionMatcher; import org.zwobble.mammoth.xml.XmlElement; @@ -21,11 +21,11 @@ import java.util.Optional; import static com.natpryce.makeiteasy.MakeItEasy.*; import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.zwobble.mammoth.results.Warning.warning; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; -import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.CHILDREN; -import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.PARAGRAPH; +import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.*; import static org.zwobble.mammoth.tests.docx.BodyXmlReaderMakers.*; import static org.zwobble.mammoth.util.MammothLists.list; import static org.zwobble.mammoth.util.MammothMaps.map; @@ -171,7 +171,7 @@ public class BodyXmlTests { XmlElement element = runXml(list( element("w:rPr", list( element("w:rStyle", map("w:val", "Heading1Char")))))); - + assertThat( read(a(bodyReader), element), isResult( @@ -179,6 +179,15 @@ public class BodyXmlTests { list(warning("Run style with ID Heading1Char was referenced but not defined in the document")))); } + @Test + public void runIsNotBoldIfBoldElementIsNotPresent() { + XmlElement element = runXmlWithProperties(); + + assertThat( + readSuccess(a(bodyReader), element), + hasProperty("bold", equalTo(false))); + } + private static DocumentElement readSuccess(Maker<BodyXmlReader> reader, XmlElement element) { Result<DocumentElement> result = read(reader, element); assertThat(result.getWarnings(), deepEquals(list())); @@ -202,6 +211,10 @@ public class BodyXmlTests { return element("w:r", children); } + private XmlElement runXmlWithProperties(XmlNode... children) { + return element("w:r", list(element("w:rPr", asList(children)))); + } + private XmlElement textXml(String value) { return element("w:t", list(XmlNodes.text(value))); } @@ -237,7 +250,7 @@ public class BodyXmlTests { } private Run run(DocumentElement... children) { - return new Run(Optional.empty(), asList(children)); + return make(a(RUN, with(CHILDREN, asList(children)))); } private Text text(String value) { |
