Skip to content

Commit

Permalink
Add safety test for options modification
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed Oct 22, 2018
1 parent a1a79b3 commit e3402fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/types/any.js
Expand Up @@ -187,6 +187,19 @@ describe('any', () => {

describe('options()', () => {

it('does not modify provided options', () => {

const options = { convert: true };
const schema = Joi.object().options(options);
schema.validate({});
expect(options).to.equal({ convert: true });

const options2 = { convert: false };
Joi.validate({}, schema, options2);
expect(options).to.equal({ convert: true });
expect(options2).to.equal({ convert: false });
});

it('adds to existing options', async () => {

const schema = Joi.object({ b: Joi.number().strict().options({ convert: true }) });
Expand Down

0 comments on commit e3402fe

Please sign in to comment.