diff options
author | 2023-05-01 16:43:45 +0200 | |
---|---|---|
committer | 2023-05-02 13:57:39 +0200 | |
commit | ce3150c65d14273539362f24afd43ee689cdb287 (patch) | |
tree | d232976b96f13cce26de3f10f47dd73ba9d3d74d /src/utils | |
parent | 3f6c8f0eddc51798d62c9011e5179f6cc497e88e (diff) | |
download | it-tools-ce3150c65d14273539362f24afd43ee689cdb287.tar.gz it-tools-ce3150c65d14273539362f24afd43ee689cdb287.tar.zst it-tools-ce3150c65d14273539362f24afd43ee689cdb287.zip |
feat(new tool): phone parser and normalizer
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/boolean.test.ts | 9 | ||||
-rw-r--r-- | src/utils/boolean.ts | 6 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/utils/boolean.test.ts b/src/utils/boolean.test.ts index 57ca10a..52bda9e 100644 --- a/src/utils/boolean.test.ts +++ b/src/utils/boolean.test.ts @@ -1,6 +1,6 @@ import _ from 'lodash'; import { describe, expect, it } from 'vitest'; -import { isNotThrowing } from './boolean'; +import { booleanToHumanReadable, isNotThrowing } from './boolean'; describe('boolean utils', () => { describe('isNotThrowing', () => { @@ -13,4 +13,11 @@ describe('boolean utils', () => { ).to.eql(false); }); }); + + describe('booleanToHumanReadable', () => { + it('should return "Yes" if the value is true and "No" otherwise', () => { + expect(booleanToHumanReadable(true)).to.eql('Yes'); + expect(booleanToHumanReadable(false)).to.eql('No'); + }); + }); }); diff --git a/src/utils/boolean.ts b/src/utils/boolean.ts index 9e842ea..cf10b37 100644 --- a/src/utils/boolean.ts +++ b/src/utils/boolean.ts @@ -1,4 +1,4 @@ -export { isNotThrowing }; +export { isNotThrowing, booleanToHumanReadable }; function isNotThrowing(cb: () => unknown): boolean { try { @@ -8,3 +8,7 @@ function isNotThrowing(cb: () => unknown): boolean { return false; } } + +function booleanToHumanReadable(value: boolean): string { + return value ? 'Yes' : 'No'; +} |