summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/1-config.js50
-rw-r--r--test/4-langs.js31
-rw-r--r--test/6-parse.js25
-rw-r--r--test/mock.js2
4 files changed, 82 insertions, 26 deletions
diff --git a/test/1-config.js b/test/1-config.js
index 474ffea..3ec76ca 100644
--- a/test/1-config.js
+++ b/test/1-config.js
@@ -2,38 +2,56 @@ var mock = require('./mock');
describe('Config', function() {
- describe('config.load()', function() {
- it('should not fail if no configuration file', function() {
+ describe('No configuration', function() {
+ var book;
+
+ before(function() {
return mock.setupDefaultBook()
- .then(function(book) {
+ .then(function(_book) {
+ book = _book;
return book.prepareConfig();
});
});
- it('should load from a JSON file', function() {
+ it('should signal that configuration is not defined', function() {
+ book.config.exists().should.not.be.ok();
+ });
+ });
+
+ describe('JSON file', function() {
+ var book;
+
+ before(function() {
return mock.setupDefaultBook({
'book.json': { title: 'Hello World' }
})
- .then(function(book) {
- return book.prepareConfig()
- .then(function() {
- book.config.get('title', '').should.equal('Hello World');
- });
+ .then(function(_book) {
+ book = _book;
+ return book.prepareConfig();
});
});
- it('should load from a JS file', function() {
+ it('should correctly extend configuration', function() {
+ book.config.get('title', '').should.equal('Hello World');
+ });
+ });
+
+ describe('JS file', function() {
+ var book;
+
+ before(function() {
return mock.setupDefaultBook({
'book.js': 'module.exports = { title: "Hello World" };'
})
- .then(function(book) {
- return book.prepareConfig()
- .then(function() {
- book.config.get('title', '').should.equal('Hello World');
- });
+ .then(function(_book) {
+ book = _book;
+ return book.prepareConfig();
});
});
- });
+ it('should correctly extend configuration', function() {
+ book.config.get('title', '').should.equal('Hello World');
+ });
+ });
});
diff --git a/test/4-langs.js b/test/4-langs.js
index 599cb43..dbde992 100644
--- a/test/4-langs.js
+++ b/test/4-langs.js
@@ -18,18 +18,29 @@ describe('Langs', function() {
});
});
- it('should parse languages list', function() {
- return mock.setupDefaultBook({
- 'LANGS.md': '# Languages\n\n'
- + '* [en](./en)\n'
- + '* [fr](./fr)\n\n'
- })
- .then(function(book) {
- return book.langs.load()
- .then(function() {
- book.langs.count().should.equal(2);
+ describe('Non-empty languages list', function() {
+ var book;
+
+ before(function() {
+ return mock.setupDefaultBook({
+ 'LANGS.md': '# Languages\n\n'
+ + '* [en](./en)\n'
+ + '* [fr](./fr)\n\n'
+ })
+ .then(function(_book) {
+ book = _book;
+
+ return book.langs.load();
});
});
+
+ it('should correctly count languages', function() {
+ book.langs.count().should.equal(2);
+ });
+
+ it('should correctly define book as multilingual', function() {
+ book.isMultilingual().should.equal(true);
+ });
});
});
diff --git a/test/6-parse.js b/test/6-parse.js
index 422744d..a575720 100644
--- a/test/6-parse.js
+++ b/test/6-parse.js
@@ -18,5 +18,30 @@ describe('Parsing', function() {
return book.parse().should.be.rejected;
});
});
+
+
+ describe('Multilingual book', function() {
+ var book;
+
+ before(function() {
+ return mock.setupBook({
+ 'LANGS.md': '# Languages\n\n'
+ + '* [English](./en)\n'
+ + '* [French](./fr)\n\n',
+ 'en/README.md': '# English',
+ 'en/SUMMARY.md': '# Summary',
+ 'fr/README.md': '# French',
+ 'fr/SUMMARY.md': '# Summary'
+ })
+ .then(function(_book) {
+ book = _book;
+ return book.parse();
+ });
+ });
+
+ it('should list language books', function() {
+
+ });
+ });
});
diff --git a/test/mock.js b/test/mock.js
index f562fa9..919a992 100644
--- a/test/mock.js
+++ b/test/mock.js
@@ -35,11 +35,13 @@ function setupFS(fs, rootFolder, files) {
// Setup a mock book for testing using a map of files
function setupBook(files, opts) {
opts = opts || {};
+ opts.log = function() { };
return Q.nfcall(tmp.dir.bind(tmp)).get(0)
.then(function(folder) {
opts.fs = fs;
opts.root = folder;
+
return setupFS(fs, folder, files);
})
.then(function(fs) {