-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
70d2b0f
commit e7cfedd
Showing
5 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @file Type Tests - isBoolean | ||
* @module tutils/guards/tests/unit-d/isBoolean | ||
*/ | ||
|
||
import type testSubject from '../is-boolean' | ||
|
||
describe('unit-d:guards/isBoolean', () => { | ||
it('should guard boolean', () => { | ||
expectTypeOf<typeof testSubject>().guards.toBeBoolean() | ||
}) | ||
}) |
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,20 @@ | ||
/** | ||
* @file Unit Tests - isBoolean | ||
* @module tutils/guards/tests/unit/isBoolean | ||
*/ | ||
|
||
import testSubject from '../is-boolean' | ||
|
||
describe('unit:guards/isBoolean', () => { | ||
it('should return false if value is not a boolean', () => { | ||
expect(testSubject(faker.number.int())).to.be.false | ||
}) | ||
|
||
it('should return true if value is a boolean', () => { | ||
// Arrange | ||
const cases: Parameters<typeof testSubject>[] = [[false], [true]] | ||
|
||
// Act + Expect | ||
cases.forEach(([value]) => expect(testSubject(value)).to.be.true) | ||
}) | ||
}) |
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,16 @@ | ||
/** | ||
* @file Type Guards - isBoolean | ||
* @module tutils/guards/isBoolean | ||
*/ | ||
|
||
/** | ||
* Checks if the given `value` is a boolean. | ||
* | ||
* @param {unknown} value - Value to evaluate | ||
* @return {value is boolean} `true` if `value` is a boolean | ||
*/ | ||
const isBoolean = (value: unknown): value is boolean => { | ||
return typeof value === 'boolean' | ||
} | ||
|
||
export default isBoolean |
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