diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-04 08:28:03 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-04 13:34:16 +0000 |
| commit | 8408269bfec3cd2f92e02075cb05ef1a4772402d (patch) | |
| tree | 9697ff393175d9f966932a68c9cdf10e44faeb45 /tests | |
| parent | 53804571b26abb1d020a4fc6a05be546c787b30a (diff) | |
Handle missing run styles in the source document
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/docx/body-reader.tests.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/docx/body-reader.tests.js b/tests/docx/body-reader.tests.js index 9c93569..e36bccc 100644 --- a/tests/docx/body-reader.tests.js +++ b/tests/docx/body-reader.tests.js @@ -69,7 +69,7 @@ describe("readXmlElement: ", function() { var paragraph = result.value; assert.deepEqual(paragraph.styleId, "Heading1"); assert.deepEqual(paragraph.styleName, null); - assert.deepEqual(result.messages, [warning("Style with ID Heading1 was referenced but not defined in the document")]); + assert.deepEqual(result.messages, [warning("Paragraph style with ID Heading1 was referenced but not defined in the document")]); }); test("paragraph has justification read from paragraph properties if present", function() { @@ -146,7 +146,7 @@ describe("readXmlElement: ", function() { assert.deepEqual(run.styleId, null); }); - test("run has style ID read from run properties if present", function() { + test("run has style ID and name read from run properties if present", function() { var runStyleXml = new XmlElement("w:rStyle", {"w:val": "Heading1Char"}); var runXml = runWithProperties([runStyleXml]); @@ -154,16 +154,20 @@ describe("readXmlElement: ", function() { var run = readXmlElementValue(runXml, {styles: styles}); assert.deepEqual(run.styleId, "Heading1Char"); + assert.deepEqual(run.styleName, "Heading 1 Char"); }); - test("run has style name read from run properties and styles", function() { + test("warning is emitted when run style cannot be found", function() { var runStyleXml = new XmlElement("w:rStyle", {"w:val": "Heading1Char"}); var runXml = runWithProperties([runStyleXml]); - var styles = new Styles({}, {"Heading1Char": {name: "Heading 1 Char"}}); + var styles = new Styles({}, {}); - var run = readXmlElementValue(runXml, {styles: styles}); - assert.deepEqual(run.styleName, "Heading 1 Char"); + var result = readXmlElement(runXml, {styles: styles}); + var run = result.value; + assert.deepEqual(run.styleId, "Heading1Char"); + assert.deepEqual(run.styleName, null); + assert.deepEqual(result.messages, [warning("Run style with ID Heading1Char was referenced but not defined in the document")]); }); test("isBold is false if bold element is not present", function() { |
