aboutsummaryrefslogtreecommitdiff
path: root/tests/document-to-html.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-01 22:21:56 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-01 22:21:56 +0100
commit720f997476ab2d0ac3cef17b890b423133ae5e7d (patch)
treeb0af74d498a82a6161af1aa0ca3fd39f32c19a8a /tests/document-to-html.tests.js
parenta70e8e05948c593fdc253b6d0a256d7aa656d988 (diff)
Generate images using data URIs
Diffstat (limited to 'tests/document-to-html.tests.js')
-rw-r--r--tests/document-to-html.tests.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index 7c84482..f8ea482 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -1,4 +1,5 @@
var assert = require("assert");
+var q = require("q");
var documents = require("../lib/documents");
var DocumentConverter = require("../lib/document-to-html").DocumentConverter;
@@ -7,6 +8,14 @@ var styles = require("../lib/styles");
describe('DocumentConverter', function() {
+ test('should empty document to empty string', function() {
+ var document = new documents.Document([]);
+ var converter = new DocumentConverter();
+ return converter.convertToHtml(document).then(function(result) {
+ assert.equal(result.html, "");
+ });
+ });
+
test('should convert document containing one paragraph to single p element', function() {
var document = new documents.Document([
paragraphOfText("Hello.")
@@ -142,6 +151,19 @@ describe('DocumentConverter', function() {
assert.equal(result.html, '<a href="http://www.example.com">Hello.</a>');
});
});
+
+ test('images are written with data URIs', function() {
+ var imageBuffer = new Buffer("Not an image at all!");
+ var image = new documents.Image(
+ function() {
+ return q.when(imageBuffer);
+ }
+ );
+ var converter = new DocumentConverter();
+ return converter.convertToHtml(image).then(function(result) {
+ assert.equal(result.html, '<img src="data:image/png;base64,' + imageBuffer.toString("base64") + '" />');
+ });
+ });
});
function paragraphOfText(text, styleName) {