aboutsummaryrefslogtreecommitdiff
path: root/tests/style-applicator.tests.js
blob: 26e00e0365fe069a07e06fdd9b778eb8cc38f400 (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 StyleApplicator = require("../lib/style-applicator").StyleApplicator;
var documents = require("../lib/documents");

var testing = require("./testing");
var test = testing.test;
var testData = testing.testData;


describe("style-applicator", function() {
    test("can process styleless document with single, center-aligned paragraph", function() {
        var testOptions = {
            styleMap: [],
            styleApplicator: {
                alignment: true
            }
        };
        var testDocument = documents.Document([
            documents.Paragraph([
                documents.Run([
                    documents.Text("Test document with centered paragraph.")
                ])
            ], {alignment: 'center'})
        ]);
        var expectedDocument = documents.Document([
            documents.Paragraph([
                documents.Run([
                    documents.Text("Test document with centered paragraph.")
                ])
            ], {styleName: 'centerAligned', alignment: 'center'})
        ]);

        var styleApplicator = new StyleApplicator(testOptions);
        return styleApplicator.processDocumentStyles(testDocument).then(function(result) {
            assert.deepEqual(expectedDocument, result);
        });
    });
});