summaryrefslogtreecommitdiffstats
path: root/test/plugins.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-18 17:14:55 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-18 17:14:55 +0200
commitd07aa13822230ee5086bafcb9ea16cb8447fb562 (patch)
tree14259c6254d20919a9964f96f5e90133af1cc689 /test/plugins.js
parentc218f7d0e30d8088ebd09951691647ffed7fe91d (diff)
downloadgitbook-d07aa13822230ee5086bafcb9ea16cb8447fb562.zip
gitbook-d07aa13822230ee5086bafcb9ea16cb8447fb562.tar.gz
gitbook-d07aa13822230ee5086bafcb9ea16cb8447fb562.tar.bz2
Add tests for page hook
Diffstat (limited to 'test/plugins.js')
-rw-r--r--test/plugins.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/plugins.js b/test/plugins.js
index 8d386af..392024a 100644
--- a/test/plugins.js
+++ b/test/plugins.js
@@ -6,6 +6,7 @@ var registry = require('../lib/plugins/registry');
var Output = require('../lib/output/base');
var PluginsManager = require('../lib/plugins');
var BookPlugin = require('../lib/plugins/plugin');
+var JSONOutput = require('../lib/output/json');
var PLUGINS_ROOT = path.resolve(__dirname, 'node_modules');
@@ -229,6 +230,42 @@ describe('Plugins', function() {
global._hooks.should.deepEqual(['init']);
});
});
+
+
+ describe('Hook "page"', function() {
+ var pluginDeprecated;
+
+ before(function() {
+ pluginDeprecated = TestPlugin(book, 'test-deprecated');
+ return pluginDeprecated.load(PLUGINS_ROOT);
+ });
+
+ it('should update content using "content" property', function() {
+ return mock.setupDefaultOutput(JSONOutput)
+ .then(function(output) {
+ output.plugins.load(plugin);
+
+ return output.generate()
+ .then(function() {
+ var json = require(output.resolve('README.json'));
+ json.page.content.should.equal('Hello <p>Hello</p>\n');
+ });
+ });
+ });
+
+ it('should update content using deprecated "sections" property', function() {
+ return mock.setupDefaultOutput(JSONOutput)
+ .then(function(output) {
+ output.plugins.load(pluginDeprecated);
+
+ return output.generate()
+ .then(function() {
+ var json = require(output.resolve('README.json'));
+ json.page.content.should.equal('Hello (sections) <p>Hello</p>\n');
+ });
+ });
+ });
+ });
});
});