diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-22 10:11:44 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-22 10:11:44 +0100 |
commit | de31b900803892ef0a441ccffba5d5f6a6c42105 (patch) | |
tree | 555addb3679a767c2f51b253d40feb9016638c28 /test | |
parent | ccc585ca1fd47ea6cb24cf16b82fd58304840d9c (diff) | |
download | gitbook-de31b900803892ef0a441ccffba5d5f6a6c42105.zip gitbook-de31b900803892ef0a441ccffba5d5f6a6c42105.tar.gz gitbook-de31b900803892ef0a441ccffba5d5f6a6c42105.tar.bz2 |
Add validation of plugin's config after loading
Diffstat (limited to 'test')
-rw-r--r-- | test/plugins.js | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/test/plugins.js b/test/plugins.js index 47f9314..a525a7b 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -1,7 +1,13 @@ +var path = require('path'); + var mock = require('./mock'); var registry = require('../lib/plugins/registry'); var Output = require('../lib/output/base'); +var error = require('../lib/utils/error'); var PluginsManager = require('../lib/plugins'); +var BookPlugin = require('../lib/plugins/plugin'); + +var PLUGINS_ROOT = path.resolve(__dirname, 'node_modules'); describe('Plugins', function() { var book; @@ -20,15 +26,6 @@ describe('Plugins', function() { }); }); - describe('Loading', function() { - it('should load default plugins', function() { - return mock.outputDefaultBook(Output) - .then(function(output) { - output.plugins.count().should.be.greaterThan(0); - }); - }); - }); - describe('Installation', function() { it('should install a plugin from NPM without a specific version', function() { return registry.install(book, 'ga') @@ -65,5 +62,22 @@ describe('Plugins', function() { .should.be.fulfilledWith(1); }); }); + + describe('Loading', function() { + it('should load default plugins', function() { + return mock.outputDefaultBook(Output) + .then(function(output) { + output.plugins.count().should.be.greaterThan(0); + }); + }); + }); + + describe('Configuration', function() { + it('should fail loading a plugin with an invalid configuration', function() { + var plugin = new BookPlugin(book, 'test-config'); + return plugin.load(PLUGINS_ROOT) + .should.be.rejectedWith('Error with book\'s configuration: pluginsConfig.test-config.myProperty is required'); + }); + }); }); |