blob: 05ef2188d54d83736d21cdce9b9a3a3ad02b6dd1 (
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
|
var assert = require("assert");
var path = require("path");
var fs = require("fs");
var mammoth = require("../")
var q = require("q");
var test = require("./testing").test;
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")
});
return convertToHtml(docxFile).then(function(result) {
assert.equal("<p>Hello.</p>", result.html);
});
})
})
function createFakeDocxFile(files) {
function read(path) {
return files[path];
}
return {
read: read
};
}
function testData(testDataPath) {
var fullPath = path.join(__dirname, "test-data", testDataPath);
return q.nfcall(fs.readFile, fullPath, "utf-8");
}
function convertToHtml(docxFile) {
var converter = new mammoth.Converter();
return converter.convertToHtml(docxFile);
}
|