Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/typy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 8 additions & 2 deletions test/typy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down