lowerCase

说明

转换字符串string以空格分开单词, 并转换为小写

源码

用法

lowerCase.test.ts
1
import { lowerCase } from "../../utility/string/lowerCase";
2
3
describe('lowerCase tests...', () => {
4
5
test('lowerCase should return `` when receive an empty string', () => {
6
const received = '';
7
const expected = '';
8
9
const result = lowerCase(received);
10
11
expect(result).toBe(expected);
12
});
13
14
test('lowerCase should return the converted string correctly', () => {
15
const received = ['--Duan-Zhao--', 'alioeDuan', '__DUAN_ZHAO_YANG__'];
16
const expected = ['duan zhao', 'alioeduan', 'duan zhao yang'];
17
18
received.forEach((v, i) => {
19
const result = lowerCase(v);
20
21
expect(result).toBe(expected[i]);
22
});
23
});
24
25
});
Copied!
最近更新 1yr ago
复制链接