summaryrefslogtreecommitdiffstats
path: root/test/assets-inliner.js
blob: cb02e429bb6a6c653dce1b6b867c945ea71588f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var cheerio = require('cheerio');

var mock = require('./mock');
var AssetsInliner = require('../lib/output/assets-inliner');

describe('Assets Inliner Output', function() {

    describe('SVG', function() {
        var output;

        before(function() {
            var SVG = '<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 mock.outputDefaultBook(AssetsInliner, {
                'README.md': '![image](test.svg)',
                'inline.md': 'This is a svg: '+SVG,
                'test.svg': '<?xml version="1.0" encoding="UTF-8"?>' + SVG
            })
            .then(function(_output) {
                output = _output;
            });
        });

        it('should correctly SVG files convert to PNG', function() {
            var page = output.book.getPage('README.md');
            var $ = cheerio.load(page.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);
        });

        it('should correctly inline SVG convert to PNG', function() {
            var page = output.book.addPage('README.md');
            var $ = cheerio.load(page.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);
        });
    });

    describe('Remote Assets', function() {

    });
});