Skip to content

Commit

Permalink
Use more specific validation for engine objects (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansamines authored Nov 6, 2022
1 parent 9266d81 commit 2a38189
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = class {
constructor(engine, options) {

Hoek.assert(engine, 'Missing catbox client engine');
Hoek.assert(typeof engine === 'object' || typeof engine === 'function', 'engine must be an engine object or engine prototype (function)');
Hoek.assert((typeof engine === 'object' && typeof engine.start === 'function') || typeof engine === 'function', 'engine must be an engine object or engine prototype (function)');
Hoek.assert(typeof engine === 'function' || !options, 'Can only specify options with function engine config');

const settings = Object.assign({}, internals.defaults, options);
Expand Down
5 changes: 5 additions & 0 deletions test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ describe('Client', () => {
expect(result.item).to.equal('123');
});

it('errors on invalid instance engine', () => {

expect(() => new Catbox.Client({})).to.throw();
});

it('passes options with default partition', () => {

const client = new Catbox.Client(Connection);
Expand Down

0 comments on commit 2a38189

Please sign in to comment.