summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-02-17 21:03:00 +0100
committerSamy Pesse <samypesse@gmail.com>2016-02-17 21:03:00 +0100
commite75002a96d00f608f75236344ceb4434c487d863 (patch)
tree41d1458b19be25197c7b8c698b82dce8d1fe3b80 /test
parenta68364d4d7593d43a83a1d16d71db32bde0a6465 (diff)
downloadgitbook-e75002a96d00f608f75236344ceb4434c487d863.zip
gitbook-e75002a96d00f608f75236344ceb4434c487d863.tar.gz
gitbook-e75002a96d00f608f75236344ceb4434c487d863.tar.bz2
Improve annotation with glossary terms
Diffstat (limited to 'test')
-rw-r--r--test/page.js42
1 files changed, 41 insertions, 1 deletions
diff --git a/test/page.js b/test/page.js
index 52e6d4e..b68e894 100644
--- a/test/page.js
+++ b/test/page.js
@@ -9,6 +9,10 @@ describe('Page', function() {
'heading.md': '# Hello\n\n## World',
'links.md': '[link](hello.md) [link 2](variables/page/next.md) [readme](README.md)',
+ 'annotations/simple.md': 'A magicien say abracadabra!',
+ 'annotations/code.md': 'A magicien say `abracadabra`!',
+ 'annotations/class.md': 'A magicien say <div class="no-glossary"><b>abracadabra</b>, right?</div>!',
+
'codes/simple.md': '```hello world```',
'codes/lang.md': '```js\nhello world\n```',
'codes/lang.adoc': '```js\nhello world\n```',
@@ -19,7 +23,9 @@ describe('Page', function() {
'variables/file/path.md': '{{ file.path }}',
'variables/page/title.md': '{{ page.title }}',
'variables/page/previous.md': '{{ page.previous.title }} {{ page.previous.path }}',
- 'variables/page/next.md': '{{ page.next.title }} {{ page.next.path }}'
+ 'variables/page/next.md': '{{ page.next.title }} {{ page.next.path }}',
+
+ 'GLOSSARY.md': '# Glossary\n\n\n## abracadabra\n\nthis is the description'
}, [
{
title: 'Test page.next',
@@ -186,4 +192,38 @@ describe('Page', function() {
.should.be.fulfilledWith('<p>Test Variables variables/page/title.md</p>\n');
});
});
+
+ describe('Annotations / Glossary', function() {
+ it('should replace glossary terms', function() {
+ return book.addPage('annotations/simple.md').toHTML(output)
+ .should.finally.be.html({
+ '.glossary-term': {
+ count: 1,
+ text: 'abracadabra',
+ attributes: {
+ title: 'this is the description',
+ href: '../GLOSSARY.html#abracadabra'
+ }
+ }
+ });
+ });
+
+ it('should not replace terms in code blocks', function() {
+ return book.addPage('annotations/code.md').toHTML(output)
+ .should.finally.be.html({
+ '.glossary-term': {
+ count: 0
+ }
+ });
+ });
+
+ it('should not replace terms in ".no-glossary"', function() {
+ return book.addPage('annotations/class.md').toHTML(output)
+ .should.finally.be.html({
+ '.glossary-term': {
+ count: 0
+ }
+ });
+ });
+ });
});