From 8a1bbc31aeb561fb2652908a349c0a3741b786f8 Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Thu, 27 Jun 2019 00:08:24 -0700 Subject: [PATCH] Remove Joi.describe(). For #1941 --- lib/index.js | 6 ------ test/index.js | 4 ++-- test/types/alternatives.js | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6e9db172d..7c888e18b 100755 --- a/lib/index.js +++ b/lib/index.js @@ -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); diff --git a/test/index.js b/test/index.js index bd16c6da3..479f5d838 100755 --- a/test/index.js +++ b/test/index.js @@ -2666,7 +2666,7 @@ describe('Joi', () => { it('describes schema (root)', () => { - const description = Joi.describe(schema); + const description = schema.describe(); expect(description).to.equal(result); }); @@ -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); }); diff --git a/test/types/alternatives.js b/test/types/alternatives.js index b8ede16af..c396665a9 100755 --- a/test/types/alternatives.js +++ b/test/types/alternatives.js @@ -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', @@ -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', @@ -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', @@ -1570,7 +1570,7 @@ describe('alternatives', () => { } }; - expect(Joi.describe(schema)).to.equal(outcome); + expect(schema.describe()).to.equal(outcome); }); it('describes when (with schema)', () => { @@ -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)', () => { @@ -1635,7 +1635,7 @@ describe('alternatives', () => { }] }; - expect(Joi.describe(schema)).to.equal(outcome); + expect(schema.describe()).to.equal(outcome); }); });