diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-27 15:58:28 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-27 15:58:28 +0100 |
commit | 750fb862d4e2d68cb65122c85743c0957ca3a3f1 (patch) | |
tree | 9f671b1f01c658c87483ba71b99451e208d6b6b3 /test/plugins.js | |
parent | 131c19dee6db956d758ed4a63ee24dbf087a8c7f (diff) | |
download | gitbook-750fb862d4e2d68cb65122c85743c0957ca3a3f1.zip gitbook-750fb862d4e2d68cb65122c85743c0957ca3a3f1.tar.gz gitbook-750fb862d4e2d68cb65122c85743c0957ca3a3f1.tar.bz2 |
Improve tests for plugins with filters
Diffstat (limited to 'test/plugins.js')
-rw-r--r-- | test/plugins.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/plugins.js b/test/plugins.js index cd46246..266596b 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -40,14 +40,39 @@ describe('Plugins', function () { var plugin = new Plugin(books[0], "filters"); plugin.load("./filters", PLUGINS_ROOT); + before(function(done) { + qdone(books[0].plugins.load(plugin), done); + }); + it('should valid a plugin', function() { assert(plugin.isValid()); }); it('should return a map of filters', function() { var filters = plugin.getFilters(); - assert.equal(_.size(filters), 1); + assert.equal(_.size(filters), 2); assert(filters["hello"]); + assert(filters["helloCtx"]); + }); + + it('should correctly extend template filters', function(done) { + qdone( + books[0].template.renderString('{{ "World"|hello }}') + .then(function(content) { + assert.equal(content, "Hello World"); + }), + done + ); + }); + + it('should correctly set book as context', function(done) { + qdone( + books[0].template.renderString('{{ "root"|helloCtx }}') + .then(function(content) { + assert.equal(content, "root:"+books[0].root); + }), + done + ); }); }); }); |