From 1c815bea595037b9255bf1f11b4b3f90dbe7c1c2 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 18 Mar 2014 14:43:00 +0000 Subject: Fix and test CLI --- tests/main.tests.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/main.tests.js (limited to 'tests/main.tests.js') diff --git a/tests/main.tests.js b/tests/main.tests.js new file mode 100644 index 0000000..1093027 --- /dev/null +++ b/tests/main.tests.js @@ -0,0 +1,31 @@ +var assert = require("assert"); +var child_process = require("child_process"); + +var promises = require("../lib/promises"); +var test = require("./testing").test; +var testPath = require("./testing").testPath; + +describe("CLI", function() { + test("HTML is printed to stdout if output file is not set", function() { + return runMammoth(testPath("single-paragraph.docx")).then(function(result) { + assert.equal(result.stderrOutput, "") + assert.equal(result.output, "

Walking on imported air

") + }); + }); +}); + +function runMammoth() { + var args = Array.prototype.slice.call(arguments, 0); + var deferred = promises.defer(); + + var processArgs = ["node", "lib/main.js"].concat(args); + // TODO: proper escaping of args + var command = processArgs.join(" "); + child_process.exec(command, function(error, stdout, stderr) { + console.log(stderr); + assert.equal(error, null); + deferred.resolve({output: stdout, stderrOutput: stderr}); + }); + + return deferred.promise; +} -- cgit v1.2.3