-
-
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.
- Loading branch information
1 parent
ec4af99
commit 699602e
Showing
5 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Return lowercase string | ||
* | ||
* @param val - input string value | ||
* @returns lowercase string | ||
* | ||
* @example | ||
* toLower('Hello') // hello | ||
*/ | ||
const toLower = <T extends string>(val: T): Lowercase<T> => | ||
val.toLowerCase() as Lowercase<T> | ||
|
||
export { toLower } |
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,13 @@ | ||
/** | ||
* Return uppercase string | ||
* | ||
* @param val - input string value | ||
* @returns uppercase string | ||
* | ||
* @example | ||
* toUpper('Hello') // HELLO | ||
*/ | ||
const toUpper = <T extends string>(val: T): Uppercase<T> => | ||
val.toUpperCase() as Uppercase<T> | ||
|
||
export { toUpper } |
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,15 @@ | ||
import { toLower } from '@/toLower' | ||
|
||
describe('toLower', () => { | ||
const table: [string, string][] = [ | ||
['', ''], | ||
['Hello', 'hello'], | ||
['HeLlo', 'hello'], | ||
['hello', 'hello'], | ||
['Hello World', 'hello world'] | ||
] | ||
|
||
it.each(table)('toLower(%s) -> %s', (val, expected) => { | ||
expect(toLower(val)).toBe(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { toUpper } from '@/toUpper' | ||
|
||
describe('toUpper', () => { | ||
const table: [string, string][] = [ | ||
['', ''], | ||
['Hello', 'HELLO'], | ||
['hello', 'HELLO'], | ||
['Hello World', 'HELLO WORLD'] | ||
] | ||
|
||
it.each(table)('toUpper(%s) -> %s', (val, expected) => { | ||
expect(toUpper(val)).toBe(expected) | ||
}) | ||
}) |