From ca74aa92bdc45f7777a66304745b3cf153a6c98e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 6 Sep 2015 11:32:11 +0100 Subject: Add support for reading file URIs --- tests/docx/files.tests.js | 24 ++++++++++++++++++++++++ tests/test-data/tiny-picture.png | Bin 0 -> 110 bytes 2 files changed, 24 insertions(+) create mode 100644 tests/docx/files.tests.js create mode 100644 tests/test-data/tiny-picture.png (limited to 'tests') 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 Binary files /dev/null and b/tests/test-data/tiny-picture.png differ -- cgit v1.2.3