Skip to content

Commit

Permalink
Create extended Joi from a new instance of Any (#934)
Browse files Browse the repository at this point in the history
Fix missing top-level methods
  • Loading branch information
joebalancio authored and Marsup committed Jun 27, 2016
1 parent 32bf602 commit 4300be9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ internals.root = function () {

this.assert(extensions, root.extensionsSchema);

const joi = Object.assign({}, this);
const joi = Object.create(this);

for (let i = 0; i < extensions.length; ++i) {
const extension = extensions[i];
Expand Down
12 changes: 12 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2646,5 +2646,17 @@ describe('Joi', () => {
done();
});
});

it('should return a custom Joi as an instance of Any', (done) => {

const customJoi = Joi.extend({
name: 'myType'
});

const Any = require('../lib/any');
expect(customJoi).to.be.an.instanceof(Any);
done();
});

});
});

0 comments on commit 4300be9

Please sign in to comment.