blob: a66cdeebb1ea2b4164e4a670faefcfd5932c0ce3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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);
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"}})})
));
});
});
|