summaryrefslogtreecommitdiffstats
path: root/test/ebook.js
blob: 9b353d240630086dcaaa00a5f9d8e2cd815111b2 (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 fs = require('fs');
var path = require('path');

describe('eBook generator', function () {
    describe('Basic Book', function() {
        var book;

        before(function() {
            return books.generate("basic", "ebook")
                .then(function(_book) {
                    book = _book;
                });
        });

        it('should correctly output a SUMMARY.html', function() {
            book.should.have.file("SUMMARY.html");
        });

        it('should correctly copy assets', function() {
            book.should.have.file("gitbook");
            book.should.have.file("gitbook/style.css");
        });
    });

    describe('Custom styles', function() {
        var book;

        before(function() {
            return books.generate("style-print", "ebook")
                .then(function(_book) {
                    book = _book;
                });
        });

        it('should remove default print.css', function() {
            var PAGE = fs.readFileSync(
                path.join(book.options.output, "index.html"),
                { encoding: "utf-8" }
            );
            PAGE.should.be.html({
                "link": {
                    count: 1,
                    attributes: {
                        href: "./styles/print.css"
                    }
                }
            });
        });

        it('should correctly print.css', function() {
            book.should.have.file("styles");
            book.should.have.file("styles/print.css");
        });
    })
});