summaryrefslogtreecommitdiffstats
path: root/test/structure.js
blob: 0d043fec08d8b5d1f80137869c7b10ad05e66546 (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
var fs = require('fs');

var mock = require('./mock');
var WebsiteOutput = require('../lib/output/website');

/*

    Testing using configuration "structure" to use custom Readme/Summary/Glossary paths
*/

describe('Structure', function() {
    var output;

    before(function() {
        return mock.outputBook(WebsiteOutput, {
            'book.json': {
                structure: {
                    readme: 'intro.md'
                }
            },
            'SUMMARY.md': '* [Test](test.md)',
            'intro.md': 'This is the intro',
            'test.md': 'Go to [intro](intro.md)'
        })
        .then(function(_output) {
            output = _output;
        });
    });

    it('should generate index.html', function() {
        output.should.have.file('index.html');
    });

    it('should generate test.html', function() {
        output.should.have.file('test.html');
    });

    it('should correctly resolve link to Readme', function() {
        var readme = fs.readFileSync(output.resolve('test.html'), 'utf-8');

        readme.should.be.html({
            '.page-inner a': {
                count: 1,
                text: 'intro',
                attributes: {
                    href: './'
                }
            }
        });
    });
});