diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-09-14 18:26:26 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-09-14 18:26:26 +0200 |
commit | afd5465a6129e96bce62dab26a4ee41e7af7365c (patch) | |
tree | 6e500ed55e65a6f6e5991913f11850d17c8ed721 /test/codehighlighting.js | |
parent | 3bf592f870eb24d1b4753fa538bad2cbfaa98a24 (diff) | |
parent | fe604733debe42a287f3c44705e16d9d0ec85908 (diff) | |
download | gitbook-afd5465a6129e96bce62dab26a4ee41e7af7365c.zip gitbook-afd5465a6129e96bce62dab26a4ee41e7af7365c.tar.gz gitbook-afd5465a6129e96bce62dab26a4ee41e7af7365c.tar.bz2 |
Merge pull request #928 from GitbookIO/feature/highlight_block
Code highlighting extended by plugins
Diffstat (limited to 'test/codehighlighting.js')
-rw-r--r-- | test/codehighlighting.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/codehighlighting.js b/test/codehighlighting.js new file mode 100644 index 0000000..e35f37e --- /dev/null +++ b/test/codehighlighting.js @@ -0,0 +1,58 @@ +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 () { + var book, PAGE; + + before(function() { + return books.generate('highlight', 'website', { + prepare: function(_book) { + book = _book; + + 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" } + ); + }); + }); + + it('should correctly replace highlighting', function() { + PAGE.should.be.html({ + "code": { + index: 0, + text: 'code_test 1\n_code' + } + }); + }); + + it('should correctly replace highlighting with language', function() { + PAGE.should.be.html({ + "code": { + index: 1, + text: 'lang_test 2\n_lang' + } + }); + }); + + it('should correctly replace highlighting for inline code', function() { + PAGE.should.be.html({ + "code": { + index: 2, + text: 'code_test 3_code' + } + }); + }); +}); + |