Skip to content

Commit

Permalink
improve coverage for function 'toJoiObject'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiNyzhnyk committed Jun 9, 2022
1 parent 3106505 commit 2dde132
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/utilities.js
Expand Up @@ -314,7 +314,7 @@ utilities.getJoiLabel = function(joiObj) {
* @return {Object}
*/
utilities.toJoiObject = function(obj) {
if (utilities.isJoi(obj) === false && utilities.isObject(obj)) {
if (!utilities.isJoi(obj) && utilities.isObject(obj)) {
return Joi.object(obj);
}

Expand Down
6 changes: 4 additions & 2 deletions test/unit/utilities-test.js
Expand Up @@ -176,8 +176,10 @@ lab.experiment('utilities', () => {
});

lab.test('toJoiObject', () => {
expect(Joi.isSchema(Utilities.toJoiObject({}))).to.equal(true)
expect(Joi.isSchema(Utilities.toJoiObject(Joi.object()))).to.equal(true)
expect(Joi.isSchema(Utilities.toJoiObject([]))).to.equal(false);
expect(Joi.isSchema(Utilities.toJoiObject(Object.create(null)))).to.equal(true);
expect(Joi.isSchema(Utilities.toJoiObject({}))).to.equal(true);
expect(Joi.isSchema(Utilities.toJoiObject(Joi.object()))).to.equal(true);
});

lab.test('hasJoiMeta', () => {
Expand Down

0 comments on commit 2dde132

Please sign in to comment.