summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-08 20:37:25 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-08 20:37:25 +0100
commit2d74506d84e32c873a8fa34d0ab3ddaf6edc7ed1 (patch)
tree70f00f82f7314719ad8c44834b06df5ca08bf496 /tests
parentc1a3e929b7268f14619daf3eff0085a747703f7e (diff)
Add test to ensure style is undefined if run properties aren't present
Diffstat (limited to 'tests')
-rw-r--r--tests/document-xml-reader.tests.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/document-xml-reader.tests.js b/tests/document-xml-reader.tests.js
index cde4cf4..9152c01 100644
--- a/tests/document-xml-reader.tests.js
+++ b/tests/document-xml-reader.tests.js
@@ -33,11 +33,17 @@ describe("readXmlElement: ", function() {
assert.deepEqual(paragraph.styleName, "Heading1");
});
- test("reads styles from run properties", function() {
+ test("run has no style if it has no properties", function() {
+ var runXml = runWithProperties([]);
+ var run = readXmlElementValue(runXml);
+ assert.equal(run.styleName, undefined);
+ });
+
+ test("run has style name read from run properties if present", function() {
var runStyleXml = new XmlElement("w:rStyle", {"w:val": "Emphasis"});
- var runPropertiesXml = createRunPropertiesXml([runStyleXml]);
- var result = readXmlElement(runPropertiesXml);
- assert.equal(result.value.styleName, "Emphasis");
+ var runXml = runWithProperties([runStyleXml]);
+ var run = readXmlElementValue(runXml);
+ assert.equal(run.styleName, "Emphasis");
});
test("isBold is false if bold element is not present", function() {
@@ -137,6 +143,10 @@ describe("readXmlElement: ", function() {
});
});
+function runWithProperties(children) {
+ return new XmlElement("w:r", {}, [createRunPropertiesXml(children)]);
+}
+
function createRunPropertiesXml(children) {
return new XmlElement("w:rPr", {}, children);
}