summaryrefslogtreecommitdiffstats
path: root/test/glossary.js
blob: c616a51d44e2732197dc9b60cd8acb1a593c49fb (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var fs = require('fs');
var path = require('path');

describe('Glossary', function () {
    describe('Parsing', function() {
        var book;

        before(function() {
            return books.parse("glossary", "website")
                .then(function(_book) {
                    book = _book;
                });
        });

        it('should correctly list items', function() {
            book.should.have.property("glossary");
            book.glossary.should.have.lengthOf(2);
        });
    });

    describe('Generation', function() {
        var book;

        before(function() {
            return books.generate("glossary", "website")
                .then(function(_book) {
                    book = _book;
                });
        });

        it('should correctly generate a GLOSSARY.html', function() {
            book.should.have.file("GLOSSARY.html");
        });

        describe('Page Integration', function() {
            var page;

            before(function() {
                page = fs.readFileSync(
                    path.join(book.options.output, "index.html"),
                    { encoding: "utf-8" }
                );
            });

            it('should correctly replaced terms by links', function() {
                page.should.be.html(".page-inner a[href='GLOSSARY.html#test']", {
                    count: 1,
                    text: "test",
                    attributes: {
                        title: "Just a simple and easy to understand test."
                    }
                });
            });
        });
    });
});