diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-06-10 14:29:55 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-06-10 14:29:55 +0100 |
| commit | 761b49f2660e5849bb692b521d4f0b98c55a622b (patch) | |
| tree | 1f4f4ab05b5a9bfd7440000d11df299863bb2b80 /tests/docx/footnotes-reader.tests.js | |
| parent | b6056ea3236b676645cad5a55df4696ba2513d95 (diff) | |
Add footnotes reader
Diffstat (limited to 'tests/docx/footnotes-reader.tests.js')
| -rw-r--r-- | tests/docx/footnotes-reader.tests.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/docx/footnotes-reader.tests.js b/tests/docx/footnotes-reader.tests.js new file mode 100644 index 0000000..536fc55 --- /dev/null +++ b/tests/docx/footnotes-reader.tests.js @@ -0,0 +1,30 @@ +var assert = require("assert"); + +var duck = require("duck"); + +var readFootnotesXml = require("../../lib/docx/footnotes-reader").readFootnotesXml; +var XmlElement = require("../../lib/xmlreader").Element; +var test = require("../testing").test; + + +describe('readFootnotesXml', function() { + test('footnote can be looked up by ID', function() { + var footnoteBody = [new XmlElement("w:p", {}, [])]; + var footnotes = readFootnotesXml({ + root: new XmlElement("w:footnotes", {}, [ + new XmlElement("w:footnote", {"w:id": "1"}, footnoteBody) + ]) + }); + assert.strictEqual(footnotes.findFootnoteById("1").body, footnoteBody); + }); + + test('footnote is null if no footnote with that ID exists', function() { + var footnoteBody = [new XmlElement("w:p", {}, [])]; + var footnotes = readFootnotesXml({ + root: new XmlElement("w:footnotes", {}, [ + new XmlElement("w:footnote", {"w:id": "1"}, footnoteBody) + ]) + }); + assert.strictEqual(footnotes.findFootnoteById("2"), null); + }); +}); |
