chore: update helpers

This commit is contained in:
vben
2024-06-02 10:29:17 +08:00
parent 8f1b054bb1
commit fc423c3657
19 changed files with 361 additions and 353 deletions

View File

@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest';
import { capitalizeFirstLetter, toLowerCaseFirstLetter } from './letter';
import {
capitalizeFirstLetter,
toCamelCase,
toLowerCaseFirstLetter,
} from './letter';
// 编写测试用例
describe('capitalizeFirstLetter', () => {
@@ -53,3 +57,22 @@ describe('toLowerCaseFirstLetter', () => {
expect(toLowerCaseFirstLetter('123Number')).toBe('123Number');
});
});
describe('toCamelCase', () => {
it('should return the key if parentKey is empty', () => {
expect(toCamelCase('child', '')).toBe('child');
});
it('should combine parentKey and key in camel case', () => {
expect(toCamelCase('child', 'parent')).toBe('parentChild');
});
it('should handle empty key and parentKey', () => {
expect(toCamelCase('', '')).toBe('');
});
it('should handle key with capital letters', () => {
expect(toCamelCase('Child', 'parent')).toBe('parentChild');
expect(toCamelCase('Child', 'Parent')).toBe('ParentChild');
});
});