-
-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b4c1ed
commit 7194953
Showing
4 changed files
with
41 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var assert = require("assert"); | ||
|
||
var documents = require("../../lib/documents"); | ||
var DocumentXmlReader = require("../../lib/docx/document-xml-reader").DocumentXmlReader; | ||
var xml = require("../../lib/xml"); | ||
var test = require("../test")(module); | ||
var createBodyReaderForTests = require("./testing").createBodyReaderForTests; | ||
|
||
test("when body element is present then body is read", function() { | ||
var bodyReader = createBodyReaderForTests({}); | ||
var documentXmlReader = new DocumentXmlReader({ | ||
bodyReader: bodyReader | ||
}); | ||
var paragraphXml = xml.element("w:p", {}, []); | ||
var bodyXml = xml.element("w:body", {}, [paragraphXml]); | ||
var documentXml = xml.element("w:document", {}, [bodyXml]); | ||
|
||
var result = documentXmlReader.convertXmlToDocument(documentXml); | ||
|
||
assert.deepEqual(result.messages, []); | ||
assert.deepEqual(result.value, documents.document( | ||
[documents.paragraph([])], | ||
{} | ||
)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var createBodyReader = require("../../lib/docx/body-reader").createBodyReader; | ||
var defaultNumbering = require("../../lib/docx/numbering-xml").defaultNumbering; | ||
var Styles = require("../../lib/docx/styles-reader").Styles; | ||
|
||
function createBodyReaderForTests(options) { | ||
options = Object.create(options || {}); | ||
options.styles = options.styles || new Styles({}, {}); | ||
options.numbering = options.numbering || defaultNumbering; | ||
return createBodyReader(options); | ||
} | ||
|
||
exports.createBodyReaderForTests = createBodyReaderForTests; |