diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-05-14 13:39:33 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-05-14 13:39:33 +0100 |
| commit | 327b99803151111bcec37af0d2bc5df5baa3506b (patch) | |
| tree | 6fddd7f45c42b3b123de5ec81ee56f4bcf537516 /test | |
| parent | bdf33ea9172f3c32f42197135053e932f725fd91 (diff) | |
Extract data URI image converter to images module
Diffstat (limited to 'test')
| -rw-r--r-- | test/images.tests.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/images.tests.js b/test/images.tests.js index 7ba3ec9..a66cdee 100644 --- a/test/images.tests.js +++ b/test/images.tests.js @@ -1,6 +1,13 @@ var assert = require("assert"); +var hamjest = require("hamjest"); +var assertThat = hamjest.assertThat; +var contains = hamjest.contains; +var hasProperties = hamjest.hasProperties; + var mammoth = require("../"); +var documents = require("../lib/documents"); +var promises = require("../lib/promises"); var test = require("./test")(module); @@ -8,3 +15,20 @@ var test = require("./test")(module); test('mammoth.images.inline() should be an alias of mammoth.images.imgElement()', function() { assert.ok(mammoth.images.inline === mammoth.images.imgElement); }); + + +test('mammoth.images.dataUri() encodes images in base64', function() { + var imageBuffer = new Buffer("abc"); + var image = new documents.Image({ + readImage: function(encoding) { + return promises.when(imageBuffer.toString(encoding)); + }, + contentType: "image/jpeg" + }); + + return mammoth.images.dataUri(image).then(function(result) { + assertThat(result, contains( + hasProperties({tag: hasProperties({attributes: {"src": "data:image/jpeg;base64,YWJj"}})}) + )); + }); +}); |
