test: Add missing test cases

This commit is contained in:
raon0211 2024-09-14 20:31:52 +09:00
parent a02c616e56
commit ec79293feb
4 changed files with 4 additions and 3 deletions

View File

@ -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`, () => {

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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;