summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-02-13 10:43:22 +0100
committerSamy Pesse <samypesse@gmail.com>2016-02-13 10:43:22 +0100
commit272f30af532b247e2b13d2d0b59c89a041723e9a (patch)
tree5a0ee666ab8dfafaa30addf5171a0a52b3695be7 /test
parent4c6717e23488656686f276aa2b40ce1d1c7641f8 (diff)
downloadgitbook-272f30af532b247e2b13d2d0b59c89a041723e9a.zip
gitbook-272f30af532b247e2b13d2d0b59c89a041723e9a.tar.gz
gitbook-272f30af532b247e2b13d2d0b59c89a041723e9a.tar.bz2
Complete test for convertion of svgs
Diffstat (limited to 'test')
-rw-r--r--test/assets-inliner.js14
-rw-r--r--test/page.js12
2 files changed, 24 insertions, 2 deletions
diff --git a/test/assets-inliner.js b/test/assets-inliner.js
index 479d788..0636a1b 100644
--- a/test/assets-inliner.js
+++ b/test/assets-inliner.js
@@ -1,3 +1,5 @@
+var cheerio = require('cheerio');
+
var mock = require('./mock');
var AssetsInliner = require('../lib/output/assets-inliner');
@@ -9,7 +11,7 @@ describe('Assets Inliner Output', function() {
before(function() {
return mock.outputDefaultBook(AssetsInliner, {
'README.md': '![image](test.svg)',
- 'test.svg': '<svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /></svg>'
+ 'test.svg': '<?xml version="1.0" encoding="UTF-8"?><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>'
})
.then(function(_output) {
output = _output;
@@ -18,7 +20,15 @@ describe('Assets Inliner Output', function() {
it('should correctly convert to PNG', function() {
var readme = output.book.getPage('README.md');
- console.log(readme.content)
+ var $ = cheerio.load(readme.content);
+
+ // Is there an image?
+ var $img = $('img');
+ $img.length.should.equal(1);
+
+ // Does the file exists
+ var src = $img.attr('src');
+ output.should.have.file(src);
});
});
diff --git a/test/page.js b/test/page.js
index 9007c45..d844d13 100644
--- a/test/page.js
+++ b/test/page.js
@@ -38,6 +38,18 @@ describe('Page', function() {
});
});
+ describe('.relative', function() {
+ it('should correctly resolve absolute path in the book', function() {
+ var page = book.addPage('heading.md');
+ var page2 = book.addPage('folder/paths.md');
+
+ page.relative('/test.png').should.equal('test.png');
+ page.relative('test.png').should.equal('test.png');
+ page2.relative('/test.png').should.equal('../test.png');
+ page2.relative('test.png').should.equal('test.png');
+ });
+ });
+
describe('Headings', function() {
it('should add a default ID to headings', function() {
var page = book.addPage('heading.md');