Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(isBoolean): check Boolean Object #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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