-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be72859
commit 29c32c9
Showing
5 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { isBoolean } from './boolean'; | ||
|
||
// an array of values that return true for isBoolean | ||
const booleanValues = [true, false]; | ||
|
||
// an array of values that return false for isBoolean | ||
const nonBooleanValues = [ | ||
0, | ||
1, | ||
2, | ||
'0', | ||
'1', | ||
'2', | ||
{}, | ||
[], | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
() => {}, | ||
new Date(), | ||
BigInt(0), | ||
null, | ||
undefined, | ||
]; | ||
|
||
describe('isBoolean', () => { | ||
it.each(booleanValues)('should return true for %p', value => { | ||
expect(isBoolean(value)).toBe(true); | ||
}); | ||
|
||
it.each(nonBooleanValues)('should return false for %p', value => { | ||
expect(isBoolean(value)).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Returns whether the value passed is a boolean. | ||
*/ | ||
export function isBoolean(value: unknown): value is boolean { | ||
return typeof value === 'boolean'; | ||
} |