summaryrefslogtreecommitdiff
path: root/tests/docx/notes-reader.tests.js
blob: 79ffed38d2744920975c9b39860756d1736edfb7 (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
37
38
39
var assert = require("assert");

var createFootnotesReader = require("../../lib/docx/notes-reader").createFootnotesReader;
var BodyReader = require("../../lib/docx/body-reader").BodyReader;
var documents = require("../../lib/documents");
var XmlElement = require("../../lib/xml").Element;
var test = require("../testing").test;


describe('readFootnotesXml', function() {
    test('ID and body of footnote are read', function() {
        var bodyReader = new BodyReader({});
        var footnoteBody = [new XmlElement("w:p", {}, [])];
        var footnotes = createFootnotesReader(bodyReader)({
            root: new XmlElement("w:footnotes", {}, [
                new XmlElement("w:footnote", {"w:id": "1"}, footnoteBody)
            ])
        });
        assert.equal(footnotes.value.length, 1);
        assert.deepEqual(footnotes.value[0].body, [new documents.Paragraph([])]);
        assert.deepEqual(footnotes.value[0].noteId, "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 = createFootnotesReader()({
                root: new XmlElement("w:footnotes", {}, [
                    new XmlElement("w:footnote", {"w:id": "1", "w:type": type}, [])
                ])
            });
            assert.equal(footnotes.value.length, 0);
        });
    });
}