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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
var fs = require('fs');
var mock = require('./mock');
var WebsiteOutput = require('../lib/output/website');
describe('Website Output', function() {
describe('Sample Book', function() {
var output;
before(function() {
return mock.outputDefaultBook(WebsiteOutput)
.then(function(_output) {
output = _output;
});
});
it('should correctly generate an index.html', function() {
output.should.have.file('index.html');
});
it('should correctly copy assets', function() {
output.should.have.file('gitbook/gitbook.js');
output.should.have.file('gitbook/theme.js');
output.should.have.file('gitbook/images/favicon.ico');
});
it('should correctly copy plugins', function() {
output.should.have.file('gitbook/gitbook-plugin-highlight/website.css');
});
});
describe('Book with chapters', function() {
var output;
before(function() {
return mock.outputDefaultBook(WebsiteOutput, {
'hello/README.md': '# Hello',
'hello/test.md': '# Test'
}, [
{
title: 'Hello',
path: 'hello/README.md'
},
{
title: 'Test',
path: 'hello/test.md'
}
])
.then(function(_output) {
output = _output;
});
});
it('should correctly generate an index.html', function() {
output.should.have.file('index.html');
});
it('should correctly generate files in folder', function() {
output.should.have.file('hello/index.html');
output.should.have.file('hello/test.html');
});
});
describe('Multilingual Book', function() {
var output;
before(function() {
return mock.outputBook(WebsiteOutput, {
'LANGS.md': '# Languages\n\n'
+ '* [en](./en)\n'
+ '* [fr](./fr)\n\n',
'en/README.md': '# Hello',
'fr/README.md': '# Bonjour'
})
.then(function(_output) {
output = _output;
});
});
it('should correctly generate an index.html for each language', function() {
output.should.have.file('en/index.html');
output.should.have.file('fr/index.html');
});
it('should correctly copy assets', function() {
output.should.have.file('gitbook/gitbook.js');
output.should.have.file('gitbook/theme.js');
});
it('should not copy assets for each language', function() {
output.should.have.not.file('en/gitbook/gitbook.js');
output.should.have.not.file('fr/gitbook/gitbook.js');
output.should.have.not.file('en/gitbook/theme.js');
output.should.have.not.file('fr/gitbook/theme.js');
});
it('should correctly generate an index.html', function() {
output.should.have.file('index.html');
});
});
describe('Theming', function() {
var output;
before(function() {
return mock.outputDefaultBook(WebsiteOutput, {
'_layouts/website/page.html': '{% extends "website/page.html" %}{% block body %}{{ super() }}<div id="theming-added"></div>{% endblock %}'
})
.then(function(_output) {
output = _output;
});
});
it('should extend default theme', function() {
var readme = fs.readFileSync(output.resolve('index.html'), 'utf-8');
readme.should.be.html({
'#theming-added': {
count: 1
}
});
});
});
});
|