mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 11:45:26 +03:00
test: Add missing test cases
This commit is contained in:
parent
a02c616e56
commit
ec79293feb
@ -27,6 +27,7 @@ describe('trim', () => {
|
||||
const expected = `a-b-c`;
|
||||
|
||||
expect(func(string, '_-')).toBe(expected);
|
||||
expect(func(string, ['_', '-'])).toBe(expected);
|
||||
});
|
||||
|
||||
it(`\`trim\` should coerce \`chars\` to a string`, () => {
|
||||
|
@ -14,7 +14,7 @@ import { trimEnd } from './trimEnd.ts';
|
||||
* trim("##hello##", ["#", "o"]); // "hell"
|
||||
*/
|
||||
export function trim(str: string, chars?: string | string[]): string {
|
||||
if (chars == null) {
|
||||
if (chars === undefined) {
|
||||
return str.trim();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
|
||||
*/
|
||||
export function trimEnd(str: string, chars?: string | string[]): string {
|
||||
if (chars == null) {
|
||||
if (chars === undefined) {
|
||||
return str.trimEnd();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed'
|
||||
*/
|
||||
export function trimStart(str: string, chars?: string | string[]): string {
|
||||
if (chars == null) {
|
||||
if (chars === undefined) {
|
||||
return str.trimStart();
|
||||
}
|
||||
let startIndex = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user