mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
Fix boolean helpers - also add tests for all helpers, and expand config tests to test values for booleans
This commit is contained in:
35
src/node/consumer/test/helpers/boolean_helpers.test.ts
Normal file
35
src/node/consumer/test/helpers/boolean_helpers.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { BooleanHelpers } from '@helpers/boolean_helpers';
|
||||
|
||||
describe('BooleanHelpers.parseBool', () => {
|
||||
it('should return true when value is "true"', () => {
|
||||
expect(BooleanHelpers.parseBool('true', false)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true when value is "1"', () => {
|
||||
expect(BooleanHelpers.parseBool('1', false)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true when value is "yes"', () => {
|
||||
expect(BooleanHelpers.parseBool('yes', false)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when value is "false"', () => {
|
||||
expect(BooleanHelpers.parseBool('false', true)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when value is "0"', () => {
|
||||
expect(BooleanHelpers.parseBool('0', true)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when value is "no"', () => {
|
||||
expect(BooleanHelpers.parseBool('no', true)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return default value when value is undefined', () => {
|
||||
expect(BooleanHelpers.parseBool(undefined, true)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return default value when value is not "true", "1", "yes", "false", "0", or "no"', () => {
|
||||
expect(BooleanHelpers.parseBool('random', true)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user