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

var mammoth = require("../")
var styles = require("../lib/styles");

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


describe('mammoth', function() {
    test('should convert docx containing one one paragraph to single p element', function() {
        var docxFile = createFakeDocxFile({
            "word/document.xml": testData("simple/word/document.xml")
        });
        var converter = new mammoth.Converter();
        return converter.convertToHtml(docxFile).then(function(result) {
            assert.equal("<p>Hello.</p>", result.html);
        });
    });
    
    test('options are passed to document converter', function() {
        var docxFile = createFakeDocxFile({
            "word/document.xml": testData("simple/word/document.xml")
        });
        var converter = new mammoth.Converter({
            defaultParagraphStyle: styles.topLevelElement("h1")
        });
        return converter.convertToHtml(docxFile).then(function(result) {
            assert.equal("<h1>Hello.</h1>", result.html);
        });
    });
})