diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-12 23:57:43 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-12 23:57:43 +0100 |
commit | 4c6717e23488656686f276aa2b40ce1d1c7641f8 (patch) | |
tree | c728f106224cedc836b83b06609011990eac4f5a /test | |
parent | 39b6562d1445e9a6c43a377d2a978eefa6458755 (diff) | |
download | gitbook-4c6717e23488656686f276aa2b40ce1d1c7641f8.zip gitbook-4c6717e23488656686f276aa2b40ce1d1c7641f8.tar.gz gitbook-4c6717e23488656686f276aa2b40ce1d1c7641f8.tar.bz2 |
Add conversion of svg to png for assets inliner
Diffstat (limited to 'test')
-rw-r--r-- | test/all.js | 1 | ||||
-rw-r--r-- | test/assets-inliner.js | 26 | ||||
-rw-r--r-- | test/page.js | 23 |
3 files changed, 49 insertions, 1 deletions
diff --git a/test/all.js b/test/all.js index 08be793..242324b 100644 --- a/test/all.js +++ b/test/all.js @@ -13,3 +13,4 @@ require('./template'); // Output require('./output-json'); +require('./assets-inliner'); diff --git a/test/assets-inliner.js b/test/assets-inliner.js new file mode 100644 index 0000000..479d788 --- /dev/null +++ b/test/assets-inliner.js @@ -0,0 +1,26 @@ +var mock = require('./mock'); +var AssetsInliner = require('../lib/output/assets-inliner'); + +describe('Assets Inliner Output', function() { + + describe('SVG', function() { + var output; + + before(function() { + return mock.outputDefaultBook(AssetsInliner, { + 'README.md': '', + 'test.svg': '<svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /></svg>' + }) + .then(function(_output) { + output = _output; + }); + }); + + it('should correctly convert to PNG', function() { + var readme = output.book.getPage('README.md'); + console.log(readme.content) + }); + + }); +}); + diff --git a/test/page.js b/test/page.js index 01c6466..9007c45 100644 --- a/test/page.js +++ b/test/page.js @@ -7,7 +7,8 @@ describe('Page', function() { before(function() { return mock.setupDefaultBook({ 'heading.md': '# Hello\n\n## World', - 'links.md': '[link](hello.md) [readme](README.md)' + 'links.md': '[link](hello.md) [readme](README.md)', + 'folder/paths.md': '' }) .then(function(_book) { book = _book; @@ -17,6 +18,26 @@ describe('Page', function() { }); }); + describe('.resolveLocal', function() { + it('should correctly resolve path to file', function() { + var page = book.addPage('heading.md'); + + page.resolveLocal('test.png').should.equal('test.png'); + page.resolveLocal('/test.png').should.equal('test.png'); + page.resolveLocal('test/hello.png').should.equal('test/hello.png'); + page.resolveLocal('/test/hello.png').should.equal('test/hello.png'); + }); + + it('should correctly resolve path to file (2)', function() { + var page = book.addPage('folder/paths.md'); + + page.resolveLocal('test.png').should.equal('folder/test.png'); + page.resolveLocal('/test.png').should.equal('test.png'); + page.resolveLocal('test/hello.png').should.equal('folder/test/hello.png'); + page.resolveLocal('/test/hello.png').should.equal('test/hello.png'); + }); + }); + describe('Headings', function() { it('should add a default ID to headings', function() { var page = book.addPage('heading.md'); |