summaryrefslogtreecommitdiffstats
path: root/lib/output/modifiers/__tests__/fetchRemoteImages.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/modifiers/__tests__/fetchRemoteImages.js')
-rw-r--r--lib/output/modifiers/__tests__/fetchRemoteImages.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/output/modifiers/__tests__/fetchRemoteImages.js b/lib/output/modifiers/__tests__/fetchRemoteImages.js
index 543aca0..f5610a2 100644
--- a/lib/output/modifiers/__tests__/fetchRemoteImages.js
+++ b/lib/output/modifiers/__tests__/fetchRemoteImages.js
@@ -1,5 +1,8 @@
var cheerio = require('cheerio');
var tmp = require('tmp');
+var path = require('path');
+
+var URL = 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png';
describe('fetchRemoteImages', function() {
var dir;
@@ -10,16 +13,28 @@ describe('fetchRemoteImages', function() {
});
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" />');
+ var $ = cheerio.load('<img src="' + URL + '" />');
- return fetchRemoteImages(dir.name, $)
+ return fetchRemoteImages(dir.name, 'index.html', $)
.then(function() {
var $img = $('img');
- var src = '.' + $img.attr('src');
+ var src = $img.attr('src');
expect(dir.name).toHaveFile(src);
});
});
+
+ pit('should download image file and replace with relative path', function() {
+ var $ = cheerio.load('<img src="' + URL + '" />');
+
+ return fetchRemoteImages(dir.name, 'test/index.html', $)
+ .then(function() {
+ var $img = $('img');
+ var src = $img.attr('src');
+
+ expect(dir.name).toHaveFile(path.join('test', src));
+ });
+ });
});