summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@friendco.de>2014-03-30 21:30:21 -0700
committerAaron O'Mullan <aaron.omullan@friendco.de>2014-03-30 21:30:21 -0700
commit1d28ab441a9f64357804ca7f983cbe884239e6a3 (patch)
tree69f57aee463b8880cbd4d5969c16658d15cf89b1
parentd5070c0bf1fa7ed6a8669383d218a2e903847bbd (diff)
downloadgitbook-1d28ab441a9f64357804ca7f983cbe884239e6a3.zip
gitbook-1d28ab441a9f64357804ca7f983cbe884239e6a3.tar.gz
gitbook-1d28ab441a9f64357804ca7f983cbe884239e6a3.tar.bz2
Add tests for summary parsing
-rw-r--r--package.json2
-rw-r--r--test/fixtures/SUMMARY.md7
-rw-r--r--test/summary.js22
3 files changed, 30 insertions, 1 deletions
diff --git a/package.json b/package.json
index b7c9538..26ca48f 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"mocha": "1.18.2"
},
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "export TESTING=true; mocha --reporter list"
},
"repository": {
"type": "git",
diff --git a/test/fixtures/SUMMARY.md b/test/fixtures/SUMMARY.md
new file mode 100644
index 0000000..9f55e4c
--- /dev/null
+++ b/test/fixtures/SUMMARY.md
@@ -0,0 +1,7 @@
+# Summary
+
+* [Chapter 1](chapter-1/README.md)
+ * [Article 1](chapter-1/ARTICLE1.md)
+ * [Article 2](chapter-1/ARTICLE2.md)
+* [Chapter 2](chapter-2/README.md)
+* [Chapter 3](chapter-3/README.md)
diff --git a/test/summary.js b/test/summary.js
new file mode 100644
index 0000000..ea3df21
--- /dev/null
+++ b/test/summary.js
@@ -0,0 +1,22 @@
+var fs = require('fs');
+var path = require('path');
+var assert = require('assert');
+
+var summary = require('../lib/summary');
+
+
+var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.md'), 'utf8');
+var LEXED = summary(CONTENT);
+
+
+describe('Summary parsing', function () {
+ console.log(LEXED);
+ it('should detect chapters', function() {
+ assert.equal(LEXED.chapters.length, 3);
+ });
+ it('should support articles', function() {
+ assert.equal(LEXED.chapters[0].articles.length, 2);
+ assert.equal(LEXED.chapters[1].articles.length, 0);
+ assert.equal(LEXED.chapters[2].articles.length, 0);
+ });
+});