summaryrefslogtreecommitdiffstats
path: root/lib/parse/__tests__/parseSummary.js
blob: 4b4650d879dc4d6338ba6169889c2536b2f976da (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
var Book = require('../../models/book');
var createMockFS = require('../../fs/mock');

describe('parseSummary', function() {
    var parseSummary = require('../parseSummary');

    pit('should parse summary if exists', function() {
        var fs = createMockFS({
            'SUMMARY.md': '# Summary\n\n* [Hello](hello.md)'
        });
        var book = Book.createForFS(fs);

        return parseSummary(book)
        .then(function(resultBook) {
            var summary = resultBook.getSummary();
            var file = summary.getFile();

            expect(file.exists()).toBeTruthy();
        });
    });

    pit('should not fail if doesn\'t exist', function() {
        var fs = createMockFS({});
        var book = Book.createForFS(fs);

        return parseSummary(book)
        .then(function(resultBook) {
            var summary = resultBook.getSummary();
            var file = summary.getFile();

            expect(file.exists()).toBeFalsy();
        });
    });
});