summaryrefslogtreecommitdiff
path: root/tests/docx/footnotes-reader.tests.js
blob: d3226f8a7598868e7d66c487b2ac4b7956190b3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var assert = require("assert");

var readFootnotesXml = require("../../lib/docx/notes-reader").readFootnotesXml;
var XmlElement = require("../../lib/xmlreader").Element;
var test = require("../testing").test;


describe('readFootnotesXml', function() {
    test('ID and body of footnote are read', function() {
        var footnoteBody = [new XmlElement("w:p", {}, [])];
        var footnotes = readFootnotesXml({
            root: new XmlElement("w:footnotes", {}, [
                new XmlElement("w:footnote", {"w:id": "1"}, footnoteBody)
            ])
        });
        assert.equal(footnotes.length, 1);
        assert.strictEqual(footnotes[0].body, footnoteBody);
        assert.deepEqual(footnotes[0].id, "1");
    });
});

footnoteTypeIsIgnored('continuationSeparator');
footnoteTypeIsIgnored('separator');

function footnoteTypeIsIgnored(type) {
    describe('footnotes of type ' + type + ' are ignored', function() {
        test('ID and body of footnote are read', function() {
            var footnotes = readFootnotesXml({
                root: new XmlElement("w:footnotes", {}, [
                    new XmlElement("w:footnote", {"w:id": "1", "w:type": type}, [])
                ])
            });
            assert.equal(footnotes.length, 0);
        });
    });
}