summaryrefslogtreecommitdiffstats
path: root/test/glossary.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-03-09 10:43:12 +0100
committerSamy Pessé <samypesse@gmail.com>2015-03-09 10:43:12 +0100
commit34fc2831e0cf0fed01c71cec28d93472d87f455b (patch)
treea803cc907c20491ba02863b5d3dd5aedf6bfed10 /test/glossary.js
parente1594cde2c32e4ff48f6c4eff3d3d461743d74e1 (diff)
parent1bf68a5aa0703b5a1815cfe4ebb731b5fb6ed9d2 (diff)
downloadgitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.zip
gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.tar.gz
gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.tar.bz2
Merge branch 'version/2.0'
Diffstat (limited to 'test/glossary.js')
-rw-r--r--test/glossary.js37
1 files changed, 26 insertions, 11 deletions
diff --git a/test/glossary.js b/test/glossary.js
index bf40e16..5deb04c 100644
--- a/test/glossary.js
+++ b/test/glossary.js
@@ -1,20 +1,35 @@
-var fs = require('fs');
var path = require('path');
+var _ = require('lodash');
var assert = require('assert');
+var cheerio = require('cheerio');
-var glossary = require('../').parse.glossary;
+var fs = require("fs");
+var fsUtil = require("../lib/utils/fs");
-var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.md'), 'utf8');
-var LEXED = glossary(CONTENT);
-describe('Glossary parsing', function () {
- it('should only get heading + paragraph pairs', function() {
- assert.equal(LEXED.length, 5);
+describe('Glossary Generation', function () {
+ it('should correctly replace glossary terms', function(done) {
+ testGeneration(books[0], "website", function(output) {
+ var content = fs.readFileSync(path.join(output, "index.html"), { encoding: "utf8" });
+ var $ = cheerio.load(content);
+
+ var $body = $(".page-inner");
+ var $a = $("a[href='GLOSSARY.html#description']");
+ assert($a.length == 1);
+ assert($a.text() == "description");
+ }, done);
});
- it('should output simple name/description objects', function() {
- assert.equal(true, !(LEXED.some(function(e) {
- return !Boolean(e.name && e.description);
- })));
+ it('should correctly replace glossary terms in sub pages', function(done) {
+ testGeneration(books[1], "website", function(output) {
+ var content = fs.readFileSync(path.join(output, "sub/test1.html"), { encoding: "utf8" });
+ var $ = cheerio.load(content);
+
+ var $body = $(".page-inner");
+ var $a = $("a[href='../GLOSSARY.html#test']");
+ assert($a.length == 1);
+ assert($a.text() == "test");
+ assert($a.attr("title") == "a test text");
+ }, done);
});
});