summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/books/structure/README.adoc1
-rw-r--r--test/books/structure/README.md1
-rw-r--r--test/books/structure/SUMMARY.md1
-rw-r--r--test/books/structure/book.json5
-rw-r--r--test/json.js74
-rw-r--r--test/structure.js8
6 files changed, 53 insertions, 37 deletions
diff --git a/test/books/structure/README.adoc b/test/books/structure/README.adoc
new file mode 100644
index 0000000..354647f
--- /dev/null
+++ b/test/books/structure/README.adoc
@@ -0,0 +1 @@
+== Readme for the bookk
diff --git a/test/books/structure/README.md b/test/books/structure/README.md
new file mode 100644
index 0000000..94f18a8
--- /dev/null
+++ b/test/books/structure/README.md
@@ -0,0 +1 @@
+# Readme for GitHub
diff --git a/test/books/structure/SUMMARY.md b/test/books/structure/SUMMARY.md
new file mode 100644
index 0000000..ac9323c
--- /dev/null
+++ b/test/books/structure/SUMMARY.md
@@ -0,0 +1 @@
+# Summary
diff --git a/test/books/structure/book.json b/test/books/structure/book.json
new file mode 100644
index 0000000..110e0ba
--- /dev/null
+++ b/test/books/structure/book.json
@@ -0,0 +1,5 @@
+{
+ "structure": {
+ "readme": "README.adoc"
+ }
+} \ No newline at end of file
diff --git a/test/json.js b/test/json.js
index 311c80a..60baf9a 100644
--- a/test/json.js
+++ b/test/json.js
@@ -1,91 +1,91 @@
-var fs = require("fs");
-var path = require("path");
+var fs = require('fs');
+var path = require('path');
-describe("JSON generator", function () {
- describe("Basic Book", function() {
+describe('JSON generator', function () {
+ describe('Basic Book', function() {
var book;
before(function() {
- return books.generate("basic", "json")
+ 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 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");
+ it('should output a valid json', function() {
+ book.should.have.jsonfile('README.json');
});
- describe("Page Format", function() {
+ describe('Page Format', function() {
var page;
before(function() {
page = JSON.parse(
fs.readFileSync(
- path.join(book.options.output, "README.json"),
- { encoding: "utf-8" }
+ 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 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 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);
+ it('should contains no languages', function() {
+ page.should.have.property('langs').with.lengthOf(0);
});
});
});
- describe("Multilingual Book", function() {
+ describe('Multilingual Book', function() {
var book;
before(function() {
- return books.generate("languages", "json")
+ 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 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");
+ 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() {
+ describe('Page Format', function() {
var page;
before(function() {
page = JSON.parse(
fs.readFileSync(
- path.join(book.options.output, "README.json"),
- { encoding: "utf-8" }
+ path.join(book.options.output, 'README.json'),
+ { encoding: 'utf-8' }
)
);
});
- it("should contains no languages", function() {
- page.should.have.property("langs").with.lengthOf(2);
+ it('should contains no languages', function() {
+ page.should.have.property('langs').with.lengthOf(2);
});
});
});
diff --git a/test/structure.js b/test/structure.js
new file mode 100644
index 0000000..b25a021
--- /dev/null
+++ b/test/structure.js
@@ -0,0 +1,8 @@
+describe('Structure', function () {
+ it('should prioritize structure defined in book.json', function() {
+ return books.parse('structure')
+ .then(function(book) {
+ book.readmeFile.should.equal('README.adoc');
+ });
+ });
+});