summaryrefslogtreecommitdiffstats
path: root/lib/output/modifiers
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-27 17:58:35 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-27 17:58:35 +0200
commite781d6d2b1705f44fcdd950f5541917fde41323f (patch)
tree309c2378efe990dfdb650a446de0640eafd2cdfe /lib/output/modifiers
parent5b342b50ce862a4d60002451e6c1abd09a7b20ce (diff)
downloadgitbook-e781d6d2b1705f44fcdd950f5541917fde41323f.zip
gitbook-e781d6d2b1705f44fcdd950f5541917fde41323f.tar.gz
gitbook-e781d6d2b1705f44fcdd950f5541917fde41323f.tar.bz2
Add test for assets inliner
Diffstat (limited to 'lib/output/modifiers')
-rw-r--r--lib/output/modifiers/__tests__/fetchRemoteImages.js25
-rw-r--r--lib/output/modifiers/__tests__/svgToImg.js25
2 files changed, 50 insertions, 0 deletions
diff --git a/lib/output/modifiers/__tests__/fetchRemoteImages.js b/lib/output/modifiers/__tests__/fetchRemoteImages.js
new file mode 100644
index 0000000..543aca0
--- /dev/null
+++ b/lib/output/modifiers/__tests__/fetchRemoteImages.js
@@ -0,0 +1,25 @@
+var cheerio = require('cheerio');
+var tmp = require('tmp');
+
+describe('fetchRemoteImages', function() {
+ var dir;
+ var fetchRemoteImages = require('../fetchRemoteImages');
+
+ beforeEach(function() {
+ dir = tmp.dirSync();
+ });
+
+ pit('should download image file', function() {
+ var $ = cheerio.load('<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png" />');
+
+ return fetchRemoteImages(dir.name, $)
+ .then(function() {
+ var $img = $('img');
+ var src = '.' + $img.attr('src');
+
+ expect(dir.name).toHaveFile(src);
+ });
+ });
+});
+
+
diff --git a/lib/output/modifiers/__tests__/svgToImg.js b/lib/output/modifiers/__tests__/svgToImg.js
new file mode 100644
index 0000000..762a02e
--- /dev/null
+++ b/lib/output/modifiers/__tests__/svgToImg.js
@@ -0,0 +1,25 @@
+var cheerio = require('cheerio');
+var tmp = require('tmp');
+
+describe('svgToImg', function() {
+ var dir;
+ var svgToImg = require('../svgToImg');
+
+ beforeEach(function() {
+ dir = tmp.dirSync();
+ });
+
+ pit('should write svg as a file', function() {
+ var $ = cheerio.load('<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1"><rect width="200" height="100" stroke="black" stroke-width="6" fill="green"/></svg>');
+
+ return svgToImg(dir.name, $)
+ .then(function() {
+ var $img = $('img');
+ var src = '.' + $img.attr('src');
+
+ expect(dir.name).toHaveFile(src);
+ });
+ });
+});
+
+