Skip to content

Commit

Permalink
Remove Joi.describe(). For #1941
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Jun 27, 2019
1 parent 9e385f3 commit 8a1bbc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
6 changes: 0 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ internals.root = function () {
return joi;
};

root.describe = function (...args) {

const schema = args.length ? this.compile(args[0]) : any;
return schema.describe();
};

root.expression = function (...args) {

return new Template(...args);
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,7 @@ describe('Joi', () => {

it('describes schema (root)', () => {

const description = Joi.describe(schema);
const description = schema.describe();
expect(description).to.equal(result);
});

Expand All @@ -2687,7 +2687,7 @@ describe('Joi', () => {

it('includes schemas in description)', () => {

const description = Joi.describe(schema);
const description = schema.describe();
expect(description).to.equal(result);
expect(description[Joi.schema]).to.equal(schema);
});
Expand Down
22 changes: 11 additions & 11 deletions test/types/alternatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,13 +1388,13 @@ describe('alternatives', () => {

it('describes when', () => {

const schema = {
const schema = Joi.object({
a: Joi.alternatives()
.when('b', { is: 5, then: 'x' })
.when('b', { is: 6, otherwise: 'y' })
.try('z'),
b: Joi.any()
};
});

const outcome = {
type: 'object',
Expand Down Expand Up @@ -1460,17 +1460,17 @@ describe('alternatives', () => {
}
};

expect(Joi.describe(schema)).to.equal(outcome);
expect(schema.describe()).to.equal(outcome);
});

it('describes when (only then)', () => {

const schema = {
const schema = Joi.object({
a: Joi.alternatives()
.when('b', { is: 5, then: 'x' })
.try('z'),
b: Joi.any()
};
});

const outcome = {
type: 'object',
Expand Down Expand Up @@ -1515,17 +1515,17 @@ describe('alternatives', () => {
}
};

expect(Joi.describe(schema)).to.equal(outcome);
expect(schema.describe()).to.equal(outcome);
});

it('describes when (only otherwise)', () => {

const schema = {
const schema = Joi.object({
a: Joi.alternatives()
.when('b', { is: 5, otherwise: 'y' })
.try('z'),
b: Joi.any()
};
});

const outcome = {
type: 'object',
Expand Down Expand Up @@ -1570,7 +1570,7 @@ describe('alternatives', () => {
}
};

expect(Joi.describe(schema)).to.equal(outcome);
expect(schema.describe()).to.equal(outcome);
});

it('describes when (with schema)', () => {
Expand Down Expand Up @@ -1604,7 +1604,7 @@ describe('alternatives', () => {
}]
};

expect(Joi.describe(schema)).to.equal(outcome);
expect(schema.describe()).to.equal(outcome);
});

it('describes inherited fields (from any)', () => {
Expand Down Expand Up @@ -1635,7 +1635,7 @@ describe('alternatives', () => {
}]
};

expect(Joi.describe(schema)).to.equal(outcome);
expect(schema.describe()).to.equal(outcome);
});
});

Expand Down

0 comments on commit 8a1bbc3

Please sign in to comment.