summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-10-21 18:05:40 +0200
committerSamy Pessé <samypesse@gmail.com>2015-10-21 18:05:40 +0200
commit27a43d5aea920faefc01caac9c8e5a60fa05097b (patch)
tree7efad6611750626cf2c32147bcff33760827e536 /test
parent4e90becd525e88905c44d3f8a3984885c7c9014d (diff)
parentdf1d5a06802154c5b6fb922c73365d2afceaecd9 (diff)
downloadgitbook-27a43d5aea920faefc01caac9c8e5a60fa05097b.zip
gitbook-27a43d5aea920faefc01caac9c8e5a60fa05097b.tar.gz
gitbook-27a43d5aea920faefc01caac9c8e5a60fa05097b.tar.bz2
Merge pull request #986 from GitbookIO/fix/heading_ids
Normalize ID for headings
Diffstat (limited to 'test')
-rw-r--r--test/books/headings/README.md3
-rw-r--r--test/books/headings/SUMMARY.md0
-rw-r--r--test/codehighlighting.js44
-rw-r--r--test/heading.js37
4 files changed, 62 insertions, 22 deletions
diff --git a/test/books/headings/README.md b/test/books/headings/README.md
new file mode 100644
index 0000000..b08c485
--- /dev/null
+++ b/test/books/headings/README.md
@@ -0,0 +1,3 @@
+# Hello World
+
+## Hello {#hello-custom}
diff --git a/test/books/headings/SUMMARY.md b/test/books/headings/SUMMARY.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/books/headings/SUMMARY.md
diff --git a/test/codehighlighting.js b/test/codehighlighting.js
index 9f392af..f167980 100644
--- a/test/codehighlighting.js
+++ b/test/codehighlighting.js
@@ -1,63 +1,63 @@
-var path = require("path");
-var fs = require("fs");
+var path = require('path');
+var fs = require('fs');
-var Plugin = require("../lib/plugin");
-var PLUGINS_ROOT = path.resolve(__dirname, "plugins");
+var Plugin = require('../lib/plugin');
+var PLUGINS_ROOT = path.resolve(__dirname, 'plugins');
-describe("Code Highlighting", function () {
+describe('Code Highlighting', function () {
var book, PAGE;
before(function() {
- return books.generate("highlight", "website", {
+ return books.generate('highlight', 'website', {
prepare: function(_book) {
book = _book;
- var plugin = new Plugin(book, "replace_highlight");
- plugin.load("./replace_highlight", PLUGINS_ROOT);
+ var plugin = new Plugin(book, 'replace_highlight');
+ plugin.load('./replace_highlight', PLUGINS_ROOT);
book.plugins.load(plugin);
}
})
.then(function() {
PAGE = fs.readFileSync(
- path.join(book.options.output, "index.html"),
- { encoding: "utf-8" }
+ path.join(book.options.output, 'index.html'),
+ { encoding: 'utf-8' }
);
});
});
- it("should correctly replace highlighting", function() {
+ it('should correctly replace highlighting', function() {
PAGE.should.be.html({
- "code": {
+ 'code': {
index: 0,
- text: "code_test 1\n_code"
+ text: 'code_test 1\n_code'
}
});
});
- it("should correctly replace highlighting with language", function() {
+ it('should correctly replace highlighting with language', function() {
PAGE.should.be.html({
- "code": {
+ 'code': {
index: 1,
- text: "lang_test 2\n_lang"
+ text: 'lang_test 2\n_lang'
}
});
});
- it("should correctly replace highlighting for inline code", function() {
+ it('should correctly replace highlighting for inline code', function() {
PAGE.should.be.html({
- "code": {
+ 'code': {
index: 2,
- text: "code_test 3_code"
+ text: 'code_test 3_code'
}
});
});
- it("should correctly replace highlighting for inline code with html tags", function() {
+ it('should correctly replace highlighting for inline code with html tags', function() {
PAGE.should.be.html({
- "code": {
+ 'code': {
index: 3,
- text: "code_<test>_code"
+ text: 'code_<test>_code'
}
});
});
diff --git a/test/heading.js b/test/heading.js
new file mode 100644
index 0000000..f6d65c3
--- /dev/null
+++ b/test/heading.js
@@ -0,0 +1,37 @@
+var path = require('path');
+var fs = require('fs');
+
+describe('Headings', function () {
+ var book, PAGE;
+
+ before(function() {
+ return books.generate('headings', 'website')
+ .then(function(_book) {
+ book = _book;
+
+ PAGE = fs.readFileSync(
+ path.join(book.options.output, 'index.html'),
+ { encoding: 'utf-8' }
+ );
+ });
+ });
+
+ describe('IDs', function() {
+ it('should correctly generate an ID', function() {
+ PAGE.should.be.html({
+ 'h1#hello-world': {
+ count: 1
+ }
+ });
+ });
+
+ it('should correctly accept custom ID', function() {
+ PAGE.should.be.html({
+ 'h2#hello-custom': {
+ count: 1
+ }
+ });
+ });
+ });
+});
+