From 0c898bcdb6b17d80fda0e2c8cac4c33453f58fbc Mon Sep 17 00:00:00 2001 From: filiafobico Date: Sun, 18 Oct 2020 18:22:34 -0300 Subject: [PATCH] fix(isBoolean): check Boolean Object --- src/typy.js | 6 ++++-- test/typy.test.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/typy.js b/src/typy.js index 7bcdbad..0861bac 100644 --- a/src/typy.js +++ b/src/typy.js @@ -69,8 +69,10 @@ class Typy { } get isBoolean() { - if (typeof this.input === typeof true) return true; - return false; + return ( + typeof this.input === 'boolean' || + this.input instanceof Boolean + ); } get isTrue() { diff --git a/test/typy.test.js b/test/typy.test.js index 889cc0e..313f7a9 100644 --- a/test/typy.test.js +++ b/test/typy.test.js @@ -141,9 +141,15 @@ describe('Typy', () => { }); test('should test if type is Boolean', () => { - const trueObj = true; + let trueObj = true; expect(t(trueObj).isBoolean === true).toBeTruthy(); - const falseObj = false; + // eslint-disable-next-line no-new-wrappers + trueObj = new Boolean(true); + expect(t(trueObj).isBoolean === true).toBeTruthy(); + let falseObj = false; + expect(t(falseObj).isBoolean === true).toBeTruthy(); + // eslint-disable-next-line no-new-wrappers + falseObj = new Boolean(false); expect(t(falseObj).isBoolean === true).toBeTruthy(); });