diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-01 22:21:56 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-01 22:21:56 +0100 |
| commit | 720f997476ab2d0ac3cef17b890b423133ae5e7d (patch) | |
| tree | b0af74d498a82a6161af1aa0ca3fd39f32c19a8a /tests | |
| parent | a70e8e05948c593fdc253b6d0a256d7aa656d988 (diff) | |
Generate images using data URIs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/document-to-html.tests.js | 22 |
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) { |
