-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(utils): add tests for boolean detection utils (#1288)
- Loading branch information
1 parent
0d7a5d7
commit 6f7ac89
Showing
2 changed files
with
82 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { isFalse, isTrue, getValueMapTruthyFalse } from './considerFalseAndTruthy'; | ||
|
||
describe('isFalse function', () => { | ||
test.each([ | ||
[null, true], | ||
[undefined, true], | ||
['0', true], | ||
['FALSE', true], | ||
['F', true], | ||
['N', true], | ||
['NO', true], | ||
['NONE', true], | ||
['nOnE', true], | ||
['', true], | ||
[0, true], | ||
[false, true], | ||
['1', false], | ||
['TRUE', false], | ||
[1, false], | ||
[true, false], | ||
['random string', false], | ||
[{}, false], | ||
[[], true], | ||
])('isFalse(%p) should return %p', (input, expected) => { | ||
expect(isFalse(input)).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('isTrue function', () => { | ||
test.each([ | ||
[null, false], | ||
[undefined, false], | ||
['1', true], | ||
['TRUE', true], | ||
['tRuE', true], | ||
['T', true], | ||
['Y', true], | ||
['YES', true], | ||
[1, true], | ||
[true, true], | ||
['0', false], | ||
['FALSE', false], | ||
[0, false], | ||
[false, false], | ||
['random string', false], | ||
[{}, false], | ||
[[], false], | ||
])('isTrue(%p) should return %p', (input, expected) => { | ||
expect(isTrue(input)).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('getValueMapTruthyFalse function', () => { | ||
test.each([ | ||
[null, '0'], | ||
[undefined, '0'], | ||
['0', '0'], | ||
['FALSE', '0'], | ||
['F', '0'], | ||
['N', '0'], | ||
['NO', '0'], | ||
['NONE', '0'], | ||
['', '0'], | ||
['1', '1'], | ||
['TRUE', '1'], | ||
['T', '1'], | ||
['Y', '1'], | ||
['YES', '1'], | ||
['random string', 'random string'], | ||
[1, '1'], | ||
[0, '0'], | ||
[123, 123], | ||
[true, '1'], | ||
[false, '0'], | ||
[{}, {}], | ||
[[], '0'], | ||
])('getValueMapTruthyFalse(%p) should return %p', (input, expected) => { | ||
expect(getValueMapTruthyFalse(input)).toEqual(expected); | ||
}); | ||
}); |
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