Skip to content

Commit

Permalink
fix(use): throw an error if a plugin does not provide a function
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Nov 18, 2016
1 parent 5455179 commit e50566a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/index.js
Expand Up @@ -40,6 +40,10 @@ module.exports = {
* Syntactic sugar for pluggable amqp10 Client behaviors
*/
use: function(plugin) {
if (typeof plugin !== 'function') {
throw new Error('Plugin is not a function');
}

plugin(Client);
}
};
4 changes: 4 additions & 0 deletions test/unit/client.test.js
Expand Up @@ -45,6 +45,10 @@ describe('Client', function() {
var client = new amqp.Client();
client.thing();
});

it('should throw an error if provided a plugin that is not a function', function() {
expect(function() { amqp.use({}); }).to.throw('Plugin is not a function');
});
});

describe('#connect()', function() {
Expand Down

0 comments on commit e50566a

Please sign in to comment.