summaryrefslogtreecommitdiffstats
path: root/lib/models/__tests__/glossary.js
blob: 5bf64dced2a62c8483cd3cbd90bc9a36c25463b8 (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 File = require('../file');
var Glossary = require('../glossary');
var GlossaryEntry = require('../glossaryEntry');

describe('Glossary', function() {
    var glossary = Glossary.createFromEntries(File(), [
        {
            name: 'Hello World',
            description: 'Awesome!'
        },
        {
            name: 'JavaScript',
            description: 'This is a cool language'
        }
    ]);

    describe('createFromEntries', function() {
        it('must add all entries', function() {
            var entries = glossary.getEntries();
            expect(entries.size).toBe(2);
        });

        it('must add entries as GlossaryEntries', function() {
            var entries = glossary.getEntries();
            var entry = entries.get('hello-world');
            expect(entry instanceof GlossaryEntry).toBeTruthy();
        });
    });

    describe('toText', function() {
        it('return as markdown', function() {
            return glossary.toText('.md')
            .then(function(text) {
                expect(text).toContain('# Glossary');
            });
        });
    });
});