aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-01-06 22:06:44 +0000
committerMichael Williamson <mike@zwobble.org>2014-01-06 22:06:44 +0000
commitad7500f87900f3db170c11c6cf997e0c7493babc (patch)
tree3721cfd360f6eb48dbc40100098a1e489825f0ba /tests
parent552f0309fcc96fdf12dd2ed9db309093ba3af281 (diff)
Reduce to a single export
Diffstat (limited to 'tests')
-rw-r--r--tests/mammoth.tests.js36
1 files changed, 11 insertions, 25 deletions
diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js
index a7385ca..c78bc19 100644
--- a/tests/mammoth.tests.js
+++ b/tests/mammoth.tests.js
@@ -15,16 +15,15 @@ var createFakeDocxFile = testing.createFakeDocxFile;
describe('mammoth', function() {
- test('should convert docx containing one one paragraph to single p element', function() {
+ test('should convert docx containing one paragraph to single p element', function() {
var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
- var converter = new mammoth.Converter();
- return converter.convertToHtml({path: docxPath}).then(function(result) {
+ return mammoth.convertToHtml({path: docxPath}).then(function(result) {
assert.equal(result.value, "<p>Walking on imported air</p>");
assert.deepEqual(result.messages, []);
});
});
- test('should convert Uint8Array containing one one paragraph to single p element', function() {
+ test('should convert Uint8Array containing one paragraph to single p element', function() {
var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
return q.nfcall(fs.readFile, docxPath).then(function(buffer) {
@@ -32,8 +31,7 @@ describe('mammoth', function() {
for (var i = 0; i < buffer.length; i++) {
array[i] = buffer[i];
}
- var converter = new mammoth.Converter();
- return converter.convertToHtml({uint8Array: array}).then(function(result) {
+ return mammoth.convertToHtml({uint8Array: array}).then(function(result) {
assert.equal("<p>Walking on imported air</p>", result.value);
});
});
@@ -43,15 +41,10 @@ describe('mammoth', function() {
var docxFile = createFakeDocxFile({
"word/document.xml": testData("simple/word/document.xml")
});
- var converter = new mammoth.Converter({
- styleMap: [
- {
- from: documentMatchers.paragraph(),
- to: htmlPaths.topLevelElement("h1")
- }
- ]
- });
- return converter.convertToHtml({file: docxFile}).then(function(result) {
+ var options = {
+ styleMap: "p => h1"
+ };
+ return mammoth.convertToHtml({file: docxFile}, options).then(function(result) {
assert.equal("<h1>Hello.</h1>", result.value);
});
});
@@ -61,12 +54,7 @@ describe('mammoth', function() {
"word/document.xml": testData("simple/word/document.xml")
});
var options = {
- styleMap: [
- {
- from: documentMatchers.paragraph(),
- to: htmlPaths.topLevelElement("h1")
- }
- ]
+ styleMap: "p => h1"
};
return mammoth.convertToHtml({file: docxFile}, options).then(function(result) {
assert.equal("<h1>Hello.</h1>", result.value);
@@ -74,17 +62,15 @@ describe('mammoth', function() {
});
test('inline images are included in output', function() {
- var converter = new mammoth.Converter();
var docxPath = path.join(__dirname, "test-data/tiny-picture.docx");
- return converter.convertToHtml({path: docxPath}).then(function(result) {
+ return mammoth.convertToHtml({path: docxPath}).then(function(result) {
assert.equal(result.value, '<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=" /></p>');
});
});
test('simple list is converted to list elements', function() {
- var converter = new mammoth.Converter();
var docxPath = path.join(__dirname, "test-data/simple-list.docx");
- return converter.convertToHtml({path: docxPath}).then(function(result) {
+ return mammoth.convertToHtml({path: docxPath}).then(function(result) {
assert.equal(result.value, '<ul><li>Apple</li><li>Banana</li></ul>');
});
});