From f854e23429c23451a968dfe4691fba5eb21ea21e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 9 Apr 2013 21:36:35 +0100 Subject: Replace zipfile with unzip --- tests/testing.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/testing.js') diff --git a/tests/testing.js b/tests/testing.js index af8ec94..6fef626 100644 --- a/tests/testing.js +++ b/tests/testing.js @@ -1,6 +1,7 @@ var path = require("path"); var fs = require("fs"); var q = require("q"); +var _ = require("underscore"); exports.test = test; exports.testData = testData; @@ -22,8 +23,20 @@ function testData(testDataPath) { } function createFakeDocxFile(files) { - function read(path) { - return q.when(files[path]); + function read(path, encoding) { + return q.when(files[path], function(buffer) { + if (_.isString(buffer)) { + buffer = new Buffer(buffer); + } + + if (!Buffer.isBuffer(buffer)) { + return q.reject(new Error("file was not a buffer")); + } else if (encoding) { + return q.when(buffer.toString(encoding)); + } else { + return q.when(buffer); + } + }); } function exists(path) { -- cgit v1.2.3