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

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

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

        it('should correctly list items', function() {
            book.should.have.property("summary");
            book.summary.should.have.property("chapters");
            book.summary.chapters.should.have.lengthOf(4);
        });

        it('should correctly mark non-existant entries', function() {
            book.summary.chapters[0].exists.should.have.equal(true);
            book.summary.chapters[1].exists.should.have.equal(true);
            book.summary.chapters[2].exists.should.have.equal(true);
            book.summary.chapters[3].exists.should.have.equal(false);
        });
    });

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

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

        it('should create files according to summary', function() {
            book.should.have.file("index.html");
            book.should.have.file("PAGE1.html");
            book.should.have.file("folder/PAGE2.html");
        });
    });
});