From afc9d62c146bdeec475c08ee87875271a8af8d93 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 18 Mar 2014 15:03:21 +0000 Subject: Add support for writing to output file in CLI --- tests/main.tests.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') 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, "

Walking on imported air

") }); }); + + 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), "

Walking on imported air

"); + }); + }); + }); }); function runMammoth() { @@ -29,3 +44,7 @@ function runMammoth() { return deferred.promise; } + +function createTempDir() { + return promises.nfcall(temp.mkdir, null); +} -- cgit v1.2.3