aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-09-06 11:32:11 +0100
committerMichael Williamson <mike@zwobble.org>2015-09-06 11:34:31 +0100
commitca74aa92bdc45f7777a66304745b3cf153a6c98e (patch)
tree7f7ebddc90d79363958dfd6c4d7edb9fd0a3e6e3 /tests
parente1344467f2301c122f8ce00b2ddf29db92bc90d2 (diff)
Add support for reading file URIs
Diffstat (limited to 'tests')
-rw-r--r--tests/docx/files.tests.js24
-rw-r--r--tests/test-data/tiny-picture.pngbin0 -> 110 bytes
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/docx/files.tests.js b/tests/docx/files.tests.js
new file mode 100644
index 0000000..d3f3391
--- /dev/null
+++ b/tests/docx/files.tests.js
@@ -0,0 +1,24 @@
+var path = require("path");
+var fs = require("fs");
+var assert = require("assert");
+
+var promises = require("../../lib/promises");
+var Files = require("../../lib/docx/files").Files;
+
+var testing = require("../testing");
+var test = testing.test;
+
+var readFile = promises.promisify(fs.readFile.bind(fs));
+
+
+describe("Files", function() {
+ test("can open files with file URI", function() {
+ var filePath = path.resolve(testing.testPath("tiny-picture.png"));
+ var files = new Files(null);
+ return files.read("file:///" + filePath.replace(/^\//, ""), "base64").then(function(contents) {
+ return readFile(filePath, "base64").then(function(expectedContents) {
+ assert.deepEqual(contents, expectedContents);
+ });
+ });
+ });
+});
diff --git a/tests/test-data/tiny-picture.png b/tests/test-data/tiny-picture.png
new file mode 100644
index 0000000..74cb4ba
--- /dev/null
+++ b/tests/test-data/tiny-picture.png
Binary files differ