aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-03-29 22:44:29 +0000
committerMichael Williamson <mike@zwobble.org>2013-03-29 22:44:29 +0000
commit785deeefe5e64b0a12786d3d9647e403c320b99e (patch)
tree02dad1eecc0a369f92d888234ce75fe58121e4db /tests
parentd978f126b9847f45f17f4bd8419236a99bfe99a9 (diff)
Pass options from Converter through to DocumentConverter
Diffstat (limited to 'tests')
-rw-r--r--tests/documents.tests.js10
-rw-r--r--tests/mammoth.tests.js20
2 files changed, 26 insertions, 4 deletions
diff --git a/tests/documents.tests.js b/tests/documents.tests.js
index 629e0da..d5db03a 100644
--- a/tests/documents.tests.js
+++ b/tests/documents.tests.js
@@ -17,6 +17,16 @@ describe('DocumentConverter', function() {
});
});
+ test('can use non-default HTML element for unstyled paragraphs', function() {
+ var document = new documents.Document([
+ paragraphOfText("Hello.")
+ ]);
+ var converter = new DocumentConverter({defaultParagraphStyle: styles.topLevelElement("h1")});
+ return converter.convertToHtml(document).then(function(result) {
+ assert.equal("<h1>Hello.</h1>", result.html);
+ });
+ });
+
test('text is HTML-escaped', function() {
var document = new documents.Document([
paragraphOfText("1 < 2")
diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js
index 05ef218..ba6b925 100644
--- a/tests/mammoth.tests.js
+++ b/tests/mammoth.tests.js
@@ -4,6 +4,7 @@ var fs = require("fs");
var mammoth = require("../")
var q = require("q");
var test = require("./testing").test;
+var styles = require("../lib/styles");
describe('mammoth', function() {
@@ -11,10 +12,23 @@ describe('mammoth', function() {
var docxFile = createFakeDocxFile({
"word/document.xml": testData("simple/word/document.xml")
});
- return convertToHtml(docxFile).then(function(result) {
+ 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);
+ });
+ });
})
function createFakeDocxFile(files) {
@@ -33,6 +47,4 @@ function testData(testDataPath) {
}
function convertToHtml(docxFile) {
- var converter = new mammoth.Converter();
- return converter.convertToHtml(docxFile);
}