summaryrefslogtreecommitdiffstats
path: root/lib/models/__tests__/glossary.js
blob: 2ce224c23e2bd5d85352bf072febcc945adfe283 (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
jest.autoMockOff();

describe('Glossary', function() {
    var File = require('../file');
    var Glossary = require('../glossary');
    var GlossaryEntry = require('../glossaryEntry');

    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() {
        pit('return as markdown', function() {
            return glossary.toText('.md')
            .then(function(text) {
                expect(text).toContain('# Glossary');
            });
        });
    });
});