aboutsummaryrefslogtreecommitdiff
path: root/tests/mammoth.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-03-29 18:57:02 +0000
committerMichael Williamson <mike@zwobble.org>2013-03-29 18:57:02 +0000
commit504f59e38e57b543ac87f73df53fe3a6ba34e26d (patch)
treeec6b292b8d16169e9b957864b1c3be369eb6d54d /tests/mammoth.tests.js
Very basic conversion from docx to HTML
Diffstat (limited to 'tests/mammoth.tests.js')
-rw-r--r--tests/mammoth.tests.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js
new file mode 100644
index 0000000..05ef218
--- /dev/null
+++ b/tests/mammoth.tests.js
@@ -0,0 +1,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);
+}