diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-10-13 14:31:11 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-10-13 14:31:11 +0200 |
commit | b742b29259aced60ec03d5577da96a2c7f2e1277 (patch) | |
tree | d8582baaf807233856fd2958664f7be45a03dc14 /test/plugins.js | |
parent | df5d27ab6103389294795a7fada76d46f36fc00f (diff) | |
download | gitbook-b742b29259aced60ec03d5577da96a2c7f2e1277.zip gitbook-b742b29259aced60ec03d5577da96a2c7f2e1277.tar.gz gitbook-b742b29259aced60ec03d5577da96a2c7f2e1277.tar.bz2 |
Add tests for plugins config validation
Diffstat (limited to 'test/plugins.js')
-rw-r--r-- | test/plugins.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/plugins.js b/test/plugins.js index 4f91e9a..db2d225 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -51,6 +51,37 @@ describe('Plugins', function () { }); }); + describe('Configuration', function() { + var plugin; + + before(function() { + plugin = new Plugin(book, 'testconfig'); + plugin.load('./config', PLUGINS_ROOT); + }); + + it('should throw error for invalid configuration', function() { + return plugin.validateConfig({}) + .should.be.rejectedWith('Configuration Error: pluginsConfig.testconfig.testRequired is required'); + }); + + it('should throw error for invalid types', function() { + return plugin.validateConfig({ + testRequired: 'hello' + }) + .should.be.rejectedWith('Configuration Error: pluginsConfig.testconfig.testRequired is not of a type(s) number'); + }); + + it('should extend with default values', function() { + return plugin.validateConfig({ + testRequired: 12 + }) + .should.be.fulfilledWith({ + hello: 'world', + testRequired: 12 + }); + }); + }); + describe('Resources', function() { var plugin; |