aboutsummaryrefslogtreecommitdiff
path: root/tests/docx/footnotes-reader.tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/docx/footnotes-reader.tests.js')
-rw-r--r--tests/docx/footnotes-reader.tests.js30
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);
+ });
+});