aboutsummaryrefslogtreecommitdiff
path: root/tests/buffer-tests.js
blob: 3b4a6c16facceb6209f6e2ab76e482b7c009bbd1 (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
var assert = require("assert");
var test = require("./testing").test;

var fs = require("fs");
var path = require("path");

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

describe("buffer-tests", function() {
    test('should convert docx as Buffer to one HTML paragraph', function() {
        var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
        var buffer = fs.readFileSync(docxPath);
        return mammoth.convertToHtml({buffer: buffer}).then(function(result) {
            assert.equal(result.value, "<p>Walking on imported air</p>");
            assert.deepEqual(result.messages, []);
        });
    });
    
    test('should convert docx as Buffer to plain text', function() {
        var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
        var buffer = fs.readFileSync(docxPath);
        return mammoth.extractRawText({buffer: buffer}).then(function(result) {
            assert.equal(result.value, "Walking on imported air\n\n");
            assert.deepEqual(result.messages, []);
        });
    });
});