diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/main.tests.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/main.tests.js b/tests/main.tests.js index 1093027..a97a049 100644 --- a/tests/main.tests.js +++ b/tests/main.tests.js @@ -1,5 +1,9 @@ var assert = require("assert"); var child_process = require("child_process"); +var path = require("path"); +var fs = require("fs"); + +var temp = require('temp').track(); var promises = require("../lib/promises"); var test = require("./testing").test; @@ -12,6 +16,17 @@ describe("CLI", function() { assert.equal(result.output, "<p>Walking on imported air</p>") }); }); + + test("HTML is written to file if output file is set", function() { + return createTempDir().then(function(tempDir) { + var outputPath = path.join(tempDir, "output.html"); + return runMammoth(testPath("single-paragraph.docx"), outputPath).then(function(result) { + assert.equal(result.stderrOutput, "") + assert.equal(result.output, "") + assert.equal(fs.readFileSync(outputPath), "<p>Walking on imported air</p>"); + }); + }); + }); }); function runMammoth() { @@ -29,3 +44,7 @@ function runMammoth() { return deferred.promise; } + +function createTempDir() { + return promises.nfcall(temp.mkdir, null); +} |
