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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
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", "normal");
});
it("should contains valid progress", function() {
page.should.have.property("progress");
page.progress.should.have.property("chapters").with.lengthOf(1);
page.progress.should.have.property("current");
});
it("should contains no languages", function() {
page.should.have.property("langs").with.lengthOf(0);
});
});
});
describe("Multilingual Book", function() {
var book;
before(function() {
return books.generate("languages", "json")
.then(function(_book) {
book = _book;
});
});
it("should correctly output READMEs", function() {
book.should.have.file("README.json");
book.should.have.file("en/README.json");
book.should.have.file("fr/README.json");
});
it("should output valid json", function() {
book.should.have.jsonfile("README.json");
book.should.have.jsonfile("en/README.json");
book.should.have.jsonfile("fr/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 no languages", function() {
page.should.have.property("langs").with.lengthOf(2);
});
});
});
});
|