From 761b49f2660e5849bb692b521d4f0b98c55a622b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 10 Jun 2014 14:29:55 +0100 Subject: Add footnotes reader --- tests/docx/footnotes-reader.tests.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/docx/footnotes-reader.tests.js (limited to 'tests/docx/footnotes-reader.tests.js') 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); + }); +}); -- cgit v1.2.3