diff options
author | Samy Pesse <samypesse@gmail.com> | 2015-09-14 11:28:14 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2015-09-14 11:28:14 +0200 |
commit | fa4e234bab15db4b0a8a0a13f041ef5869a2458b (patch) | |
tree | 243816b5b7a243915b44a590cb40e5ce4c731b21 /test | |
parent | 35c4179ca12a0287279ced0535f11237cdf606ec (diff) | |
download | gitbook-fa4e234bab15db4b0a8a0a13f041ef5869a2458b.zip gitbook-fa4e234bab15db4b0a8a0a13f041ef5869a2458b.tar.gz gitbook-fa4e234bab15db4b0a8a0a13f041ef5869a2458b.tar.bz2 |
Add base test for extending code highlighting
Diffstat (limited to 'test')
-rw-r--r-- | test/books/basic/README.md | 4 | ||||
-rw-r--r-- | test/books/highlight/README.md | 7 | ||||
-rw-r--r-- | test/books/highlight/SUMMARY.md | 1 | ||||
-rw-r--r-- | test/codehighlighting.js | 34 | ||||
-rw-r--r-- | test/helper.js | 16 | ||||
-rw-r--r-- | test/plugins.js | 26 |
6 files changed, 50 insertions, 38 deletions
diff --git a/test/books/basic/README.md b/test/books/basic/README.md index 73d74c0..09ade40 100644 --- a/test/books/basic/README.md +++ b/test/books/basic/README.md @@ -1,7 +1,3 @@ # Readme Default description for the book. - -``` -test -``` diff --git a/test/books/highlight/README.md b/test/books/highlight/README.md new file mode 100644 index 0000000..73d74c0 --- /dev/null +++ b/test/books/highlight/README.md @@ -0,0 +1,7 @@ +# Readme + +Default description for the book. + +``` +test +``` diff --git a/test/books/highlight/SUMMARY.md b/test/books/highlight/SUMMARY.md new file mode 100644 index 0000000..ac9323c --- /dev/null +++ b/test/books/highlight/SUMMARY.md @@ -0,0 +1 @@ +# Summary diff --git a/test/codehighlighting.js b/test/codehighlighting.js new file mode 100644 index 0000000..a64bf4b --- /dev/null +++ b/test/codehighlighting.js @@ -0,0 +1,34 @@ +var _ = require('lodash'); +var should = require('should'); +var path = require('path'); +var fs = require('fs'); + +var Plugin = require('../lib/plugin'); +var PLUGINS_ROOT = path.resolve(__dirname, 'plugins'); + +describe('Code Highlighting', function () { + it('should correctly replace highlighting', function() { + return books.generate('highlight', 'website', { + prepare: function(book) { + var plugin = new Plugin(book, "highlight"); + plugin.load("./highlight", PLUGINS_ROOT); + + book.plugins.load(plugin); + } + }) + .then(function(book) { + var PAGE = fs.readFileSync( + path.join(book.options.output, "index.html"), + { encoding: "utf-8" } + ); + + PAGE.should.be.html({ + "code": { + count: 1, + text: 'code_test\n_code' + } + }); + }); + }); +}); + diff --git a/test/helper.js b/test/helper.js index ef5c45c..f4432a9 100644 --- a/test/helper.js +++ b/test/helper.js @@ -17,18 +17,18 @@ var TMPDIR = os.tmpdir(); // Generate and return a book -function generateBook(bookId, test, options) { - options = _.defaults(options || {}, { - before: function() {} +function generateBook(bookId, test, opts) { + opts = _.defaults(opts || {}, { + prepare: function() {} }); return parseBook(bookId, test) .then(function(book) { - return Q(options.before(book)) - .thenResolve(book); - }) - .then(function(book) { - return book.generate(test) + + return Q(opts.prepare(book)) + .then(function() { + return book.generate(test); + }) .thenResolve(book); }); } diff --git a/test/plugins.js b/test/plugins.js index a81110c..cc9c8e6 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -235,31 +235,5 @@ describe('Plugins', function () { }); }); }); - - describe('Replace code highlighting', function() { - it('should correctly replace highlighting', function() { - return books.generate('basic', 'website', { - before: function(book) { - var plugin = new Plugin(book, "blocks"); - plugin.load("./highlight", PLUGINS_ROOT); - - return book.plugins.load(plugin); - } - }) - .then(function() { - var PAGE = fs.readFileSync( - path.join(book.options.output, "index.html"), - { encoding: "utf-8" } - ); - - PAGE.should.be.html({ - "code": { - count: 1, - text: 'code__test\n__code' - } - }); - }); - }) - }); }); |