summaryrefslogtreecommitdiffstats
path: root/test/5-summary.js
blob: 2744c430ac1f141fe443baaf280046ef519870c3 (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
var mock = require('./mock');

describe('Summary / Table of contents', function() {
    describe('Empty summary list', function() {
        var book;

        before(function() {
            return mock.setupDefaultBook({})
            .then(function(_book) {
                book = _book;
                return book.summary.load();
            });
        });

        it('should correctly count articles', function() {
            book.summary.count().should.equal(1);
        });
    });

    describe('Non-empty summary list', function() {
        var book;

        before(function() {
            return mock.setupDefaultBook({
                'SUMMARY.md': '# Summary\n\n'
                    + '* [Hello](./hello.md)\n'
                    + '* [World](./world.md)\n\n'
            })
            .then(function(_book) {
                book = _book;
                return book.summary.load();
            });
        });

        it('should correctly count articles', function() {
            book.summary.count().should.equal(3);
        });
    });
});