aboutsummaryrefslogtreecommitdiff
path: root/tests/docx/styles-reader.tests.js
blob: dd8260250a09d430031018be004cdab41f45e863 (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
var assert = require("assert");

var duck = require("duck");

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


describe('readStylesXml', function() {
    test('paragraph style is null if no style with that ID exists', function() {
        var styles = readStylesXml({
            root: new XmlElement("w:styles", {}, [])
        });
        assert.equal(styles.findParagraphStyleById("Heading1"), null);
    });
    
    test('paragraph style can be found by ID', function() {
        var styles = readStylesXml({
            root: new XmlElement("w:styles", {}, [
                new XmlElement("w:style", {"w:styleId": "Heading1"}, [
                    new XmlElement("w:name", {"w:val": "Heading 1"}, [])
                ])
            ])
        });
        assert.equal(styles.findParagraphStyleById("Heading1").styleId, "Heading1");
    });
});