aboutsummaryrefslogtreecommitdiff
path: root/tests/testing.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-09 21:36:35 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-09 21:36:35 +0100
commitf854e23429c23451a968dfe4691fba5eb21ea21e (patch)
tree4061308df30c8cae988d51b4d53686c4248db508 /tests/testing.js
parenta02b92d7b7d95ab2e8f9e2dfb8a7661b61306674 (diff)
Replace zipfile with unzip
Diffstat (limited to 'tests/testing.js')
-rw-r--r--tests/testing.js17
1 files changed, 15 insertions, 2 deletions
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) {