Skip to content

Commit

Permalink
Fix alternatives description (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed Mar 18, 2016
1 parent e60b712 commit e5b5293
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/alternatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internals.Alternatives.prototype.when = function (ref, options) {

internals.Alternatives.prototype.describe = function () {

const description = Any.prototype.describe.call(Hoek.reach(this, '_settings.baseType', { default: this }));
const description = Any.prototype.describe.call(this);
const alternatives = [];
for (let i = 0; i < this._inner.matches.length; ++i) {
const item = this._inner.matches[i];
Expand Down
7 changes: 4 additions & 3 deletions test/any.js
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,10 @@ describe('any', () => {

const schema = Joi.number().min(10).when('a', { is: 5, then: Joi.number().max(20).required() }).describe();
expect(schema).to.deep.equal({
type: 'number',
invalids: [Infinity, -Infinity],
rules: [{ name: 'min', arg: 10 }],
type: 'alternatives',
flags: {
presence: 'ignore'
},
alternatives: [{
ref: 'ref:a',
is: {
Expand Down
6 changes: 2 additions & 4 deletions test/ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,8 @@ describe('ref', () => {
.describe();

expect(desc).to.deep.equal({
type: 'any',
flags: { allowOnly: true, default: 'ref:a.b' },
valids: ['ref:a.b'],
invalids: ['context:b.c'],
type: 'alternatives',
flags: { presence: 'ignore' },
alternatives: [{
ref: 'ref:a.b',
is: {
Expand Down

0 comments on commit e5b5293

Please sign in to comment.