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

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

    it('should parse glossary if exists', function() {
        var fs = createMockFS({
            'GLOSSARY.md': '# Glossary\n\n## Hello\nDescription for hello'
        });
        var book = Book.createForFS(fs);

        return parseGlossary(book)
        .then(function(resultBook) {
            var glossary = resultBook.getGlossary();
            var file = glossary.getFile();
            var entries = glossary.getEntries();

            expect(file.exists()).toBeTruthy();
            expect(entries.size).toBe(1);
        });
    });

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

        return parseGlossary(book)
        .then(function(resultBook) {
            var glossary = resultBook.getGlossary();
            var file = glossary.getFile();

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