From fab0bf4a2bbfd8dd2219563dff702c629bd16e5b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 18 Mar 2014 17:11:55 +0000 Subject: Add --output-dir argument to CLI --- tests/main.tests.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/main.tests.js b/tests/main.tests.js index 3b56b0b..5e8f436 100644 --- a/tests/main.tests.js +++ b/tests/main.tests.js @@ -23,19 +23,35 @@ describe("CLI", function() { 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

"); + assert.equal(fs.readFileSync(outputPath, "utf8"), "

Walking on imported air

"); }); }); }); + var imageBase64 = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII="; + test("inline images are included in output if writing to single file", function() { return runMammoth(testPath("tiny-picture.docx")).then(function(result) { assert.equal(result.stderrOutput, "") - assert.equal(result.output, '

') + assert.equal(result.output, '

') + }); + }); + + test("images are written to separate files if output dir is set", function() { + return createTempDir().then(function(tempDir) { + var outputPath = path.join(tempDir, "tiny-picture.html"); + var imagePath = path.join(tempDir, "1.png"); + return runMammoth(testPath("tiny-picture.docx"), "--output-dir", tempDir).then(function(result) { + assert.equal(result.stderrOutput, "") + assert.equal(result.output, "") + assert.equal(fs.readFileSync(outputPath, "utf8"), '

'); + assert.equal(fs.readFileSync(imagePath, "base64"), imageBase64); + }); }); }); }); + function runMammoth() { var args = Array.prototype.slice.call(arguments, 0); var deferred = promises.defer(); -- cgit v1.2.3