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

describe('JSON generator', function () {
    describe('Basic Book', function() {
        var book;

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

        it('should correctly output a README.json', function() {
            book.should.have.file("README.json");
        });

        it('should output a valid json', function() {
            book.should.have.jsonfile("README.json");
        });

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

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

            it('should contains valid section', function() {
                page.should.have.property("sections").with.lengthOf(1);
                page.sections[0].should.have.property("content").which.is.a.String;
                page.sections[0].should.have.property("type").which.is.a.String.which.equal("normal");
            });

            it('should contains no languages', function() {
                page.should.have.property("langs").with.lengthOf(0);
            });
        });
    });
});