blob: c486f3b19f8555be71b45e2c6a3781686a437529 (
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
40
41
42
43
44
45
46
47
48
|
var assert = require("assert");
var docxReader = require("../lib/docx-reader");
var documents = require("../lib/documents");
var testing = require("./testing");
var test = testing.test;
var testData = testing.testData;
var createFakeDocxFile = testing.createFakeDocxFile;
describe("docx-reader", function() {
test("can read document with single paragraph with single run of text", function() {
var expectedDocument = documents.Document([
documents.Paragraph([
documents.Run([
documents.Text("Hello.")
])
])
]);
var docxFile = createFakeDocxFile({
"word/document.xml": testData("simple/word/document.xml")
});
return docxReader.read(docxFile).then(function(result) {
assert.deepEqual(expectedDocument, result);
});
});
test("can read paragraph styles", function() {
var docxFile = createFakeDocxFile({
"word/document.xml": testData("paragraphStyles/word/document.xml")
});
return docxReader.read(docxFile).then(function(result) {
var paragraph = result.children[0];
assert.deepEqual({styleName: "Heading1"}, paragraph.properties);
});
});
test("paragraph properties are not included as child of paragraph", function() {
var docxFile = createFakeDocxFile({
"word/document.xml": testData("paragraphStyles/word/document.xml")
});
return docxReader.read(docxFile).then(function(result) {
var paragraph = result.children[0];
assert.equal(1, paragraph.children.length);
});
});
});
|