diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-27 16:04:49 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-27 16:04:49 +0100 |
commit | d9329295d60a94a02719869f58abdc3da3535190 (patch) | |
tree | 9aeb7b992012a301e34dae87c5bad7b31ca36333 /test | |
parent | 750fb862d4e2d68cb65122c85743c0957ca3a3f1 (diff) | |
download | gitbook-d9329295d60a94a02719869f58abdc3da3535190.zip gitbook-d9329295d60a94a02719869f58abdc3da3535190.tar.gz gitbook-d9329295d60a94a02719869f58abdc3da3535190.tar.bz2 |
Add test for extending template blocks
Diffstat (limited to 'test')
-rw-r--r-- | test/plugins.js | 23 | ||||
-rw-r--r-- | test/plugins/blocks/index.js | 15 | ||||
-rw-r--r-- | test/plugins/blocks/package.json | 9 |
3 files changed, 47 insertions, 0 deletions
diff --git a/test/plugins.js b/test/plugins.js index 266596b..ea226a9 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -75,4 +75,27 @@ describe('Plugins', function () { ); }); }); + + describe('blocks', function() { + var plugin = new Plugin(books[0], "blocks"); + plugin.load("./blocks", PLUGINS_ROOT); + + before(function(done) { + qdone(books[0].plugins.load(plugin), done); + }); + + it('should valid a plugin', function() { + assert(plugin.isValid()); + }); + + it('should correctly extend template blocks', function(done) { + qdone( + books[0].template.renderString('{% test %}hello{% endtest %}') + .then(function(content) { + assert.equal(content, "testhellotest"); + }), + done + ); + }); + }); }); diff --git a/test/plugins/blocks/index.js b/test/plugins/blocks/index.js new file mode 100644 index 0000000..6415ec0 --- /dev/null +++ b/test/plugins/blocks/index.js @@ -0,0 +1,15 @@ +module.exports = { + blocks: { + "test": { + process: function(body, args, kwargs) { + return "test"+body+"test"; + } + }, + "test2": { + end: "endtest2end", + process: function(body, args, kwargs) { + return "test2"+body+"test2"; + } + } + } +};
\ No newline at end of file diff --git a/test/plugins/blocks/package.json b/test/plugins/blocks/package.json new file mode 100644 index 0000000..7c41fd3 --- /dev/null +++ b/test/plugins/blocks/package.json @@ -0,0 +1,9 @@ +{ + "name": "gitbook-plugin-blocks", + "description": "Test blocks", + "main": "index.js", + "version": "0.0.1", + "engines": { + "gitbook": "*" + } +}
\ No newline at end of file |